home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / xoper26.lha / Xoper / src.lha / xoper.s
Text File  |  1995-11-17  |  188KB  |  9,507 lines

  1. ******************************************
  2. *                     *
  3. * Xoper 2.6 Copyright (C) Werner GÜnther *
  4. *    (68881 code by Lothar English)      *
  5. *(Kick 2.0+ enhancements by Gunther Nikl)*
  6. *                     *
  7. ******************************************
  8. *  Written for the A68k V2.71 Assembler     *
  9. * by Charlie Gibbs and Brian R. Anderson *
  10. *                     *
  11. * Do not use Smallcode/Smalldata when     *
  12. *        linking             *
  13. ******************************************
  14.  
  15. ;DEBUG SET 1
  16.  
  17. ; revison control...
  18.  
  19. VERSION        macro
  20.         dc.b    'Xoper 2.6 (17.11.95)',0
  21.         endm
  22.  
  23. ; include stuff
  24.  
  25.         include    exec/types.i
  26.         include    lvo13/dos_lib.i
  27.         include    lvo13/exec_lib.i
  28.         include    lvo13/console_lib.i
  29.         include    lvo13/graphics_lib.i
  30.         include    lvo13/diskfont_lib.i
  31.         include    lvo13/intuition_lib.i
  32.  
  33. ; >=V36 functions
  34.  
  35. _LVOColdReboot        equ    -726        ; exec
  36. _LVOFindDisplayInfo    equ    -726        ; graphics
  37. _LVOGetDisplayInfoData    equ    -756
  38. _LVOGetVPModeID        equ    -792
  39. _LVOQueryOverscan    equ    -474        ; intuition
  40. _LVOLockPubScreen    equ    -510
  41. _LVOUnlockPubScreen    equ    -516
  42. _LVOLockPubScreenList    equ    -522
  43. _LVOUnlockPubScreenList    equ    -528
  44. _LVOPubScreenStatus    equ    -552
  45. _LVOReadEClock        equ    -60        ; timer
  46. _LVOAddAppIcon        equ    -60        ; workbench
  47. _LVORemoveAppIcon    equ    -66
  48. _LVOCreateCxObj        equ    -30        ; commodity
  49. _LVOCxBroker        equ    -36
  50. _LVOActivateCxObj    equ    -42
  51. _LVODeleteCxObjAll    equ    -54
  52. _LVOCxObjError        equ    -66
  53. _LVOAttachCxObj        equ    -84
  54. _LVOSetFilter        equ    -120
  55. _LVOCxMsgType        equ    -138
  56. _LVOCxMsgID        equ    -150
  57.  
  58. ; macro stuff
  59.  
  60. CALL        MACRO
  61.         move.l    \2,a6
  62.         jsr    _LVO\1(a6)
  63.         ENDM
  64.  
  65. RECALL        MACRO
  66.         jsr    _LVO\1(a6)
  67.         ENDM
  68.  
  69. ADDCMD        MACRO
  70. cmdnum        set    cmdnum+1
  71.         dc.b    \1,0
  72.         ENDM
  73.  
  74. ; global stuff
  75.  
  76.     STRUCTURE Globals,0
  77.  
  78.       ULONG  sysbase
  79.       ULONG  dosbase
  80.       ULONG  intuibase
  81.       ULONG  gfxbase
  82.       ULONG  wbbase
  83.       ULONG  cxbase
  84.       ULONG  condev
  85.       ULONG  wbmsg
  86.       ULONG  wblock
  87.       ULONG  savesp
  88.       ULONG  idletask
  89.       ULONG  node
  90.       ULONG  parmtxt
  91.       ULONG  ptr
  92.       ULONG  auxsig
  93.       ULONG  mysignal            ; init with $20000
  94.       ULONG  trapsig
  95.       ULONG  trapmask
  96.       ULONG  tasksigs
  97.       ULONG  cancelmask
  98.       ULONG  broker
  99.       ULONG  filter
  100.       ULONG  inputport
  101.        ULONG  inputio
  102.       ULONG  startmess
  103.       ULONG  savedat
  104.       ULONG  wnptr
  105.       ULONG  ownfont
  106.       ULONG  topazfont
  107.       ULONG  aliaslist
  108.       ULONG  screenptr
  109.       ULONG  intuimsg
  110.       ULONG  mytask
  111.       ULONG  oldprwin
  112.       ULONG  pointer
  113.       ULONG  replyport
  114.       ULONG  finfoptr
  115.       ULONG  dispatches
  116.       ULONG  maxdisp
  117.       ULONG  oldswitches
  118.       ULONG  remembr
  119.       ULONG  remembr2
  120.       ULONG  snoopport
  121.       ULONG  captask
  122.       ULONG  capiscli
  123.       ULONG  capseg
  124.       ULONG  blanks
  125.       ULONG  hidestart
  126.       ULONG  iocount
  127.       ULONG  rastport
  128.       ULONG  outchain
  129.       ULONG  firstline
  130.       ULONG  oldfirstline
  131.       ULONG  numlines
  132.       ULONG  oldnumlines
  133.       ULONG  timeoutm
  134.       ULONG  gothline
  135.       ULONG  lastprinted
  136.       ULONG  oldlastprinted
  137.       ULONG  maxlines            ; init with 500
  138.       ULONG  oldpageend
  139.       ULONG  secs
  140.       ULONG  mics
  141.       ULONG  time10
  142.       ULONG  tsecs
  143.       ULONG  tmics
  144.       ULONG  devicelock
  145.       ULONG  timerticks
  146.       ULONG  excpterror
  147.       ULONG  excpttask
  148.       ULONG  excptaddr
  149.       ULONG  excptpc
  150.       ULONG  lasttime
  151.       STRUCT newtime,4*2
  152.       STRUCT osecs,4*4
  153.       STRUCT tdtasks,4*4
  154.  
  155.       ULONG  OldSwitch
  156.       ULONG  OldAddTask
  157.       ULONG  OldAllocMem
  158.       ULONG  OldFreeMem
  159.       ULONG  OldTrap
  160.       ULONG  OldProcTrap
  161.       ULONG  div32
  162.  
  163.       UWORD  txheight
  164.       UWORD  txwidth
  165.       UWORD  firstpos
  166.       UWORD  colms
  167.       UWORD  timersig
  168.       UWORD  cxsig
  169.       UWORD  intuisig
  170.       UWORD  ibufferlen
  171.       UWORD  oldibuflen
  172.       UWORD  cposy
  173.       UWORD  curpos
  174.       UWORD  oldpos
  175.       UWORD  bottomin
  176.       UWORD  ipos
  177.       UWORD  hnum
  178.       UWORD  minnumchars            ; init with 2
  179.       UWORD  maxhlines            ; init with 10
  180.       UWORD  qualifier
  181.       UWORD  rows
  182.       UWORD  maxllength
  183.       UWORD  loffset
  184.       UWORD  repeatlen
  185.       UWORD  edline
  186.       UWORD  cmdptr
  187.       UWORD  currenty
  188.       UWORD  cmdcompnr
  189.       UWORD  cmdcomplen
  190.       UWORD  cmdcplen
  191.       UWORD  numtaskstimed
  192.       UWORD  tasksnum
  193.       UWORD  procnum
  194.  
  195.       STRUCT hexarea,10
  196.       STRUCT binarea,12
  197.       STRUCT minus,2
  198.       STRUCT decimal,6
  199.  
  200.       UBYTE  entries
  201.       UBYTE  timeout            ; init with 5
  202.       UBYTE  newpri
  203.       UBYTE  tasktyp
  204.       UBYTE  getanswer
  205.       UBYTE  printed
  206.       UBYTE  useageon
  207.       UBYTE  tports
  208.       UBYTE  hideon                ; init with
  209.       UBYTE  headon
  210.       UBYTE  tinfo
  211.       UBYTE  cmdcli                ;    |
  212.       UBYTE  sorton                ;    |
  213.       UBYTE  cxstate            ;    |
  214.       UBYTE  iconifyon            ;    V
  215.       UBYTE  propgadon
  216.       UBYTE  propupdate
  217.       UBYTE  finfopen            ; -1 !!!!
  218.       UBYTE  patchmode
  219.       UBYTE  timerstate
  220.       UBYTE  cbreak
  221.       UBYTE  bool
  222.       UBYTE  wanttraps
  223.       UBYTE  addlines
  224.       UBYTE  gotguru
  225.       UBYTE  ownscreen
  226.       UBYTE  topaz
  227.       UBYTE  insmode
  228.       UBYTE  repeat
  229.       UBYTE  capgone
  230.       UBYTE  capwaiting
  231.       UBYTE  cliexec
  232.       UBYTE  appicn
  233.       UBYTE  pcheck
  234.       UBYTE  snoopon
  235.       UBYTE  msnoop
  236.       UBYTE  newtab
  237.       UBYTE  oldtab
  238.       UBYTE  bleft
  239.       UBYTE  waitexit
  240.       UBYTE  wantexit
  241.       UBYTE  wanthold
  242.       UBYTE  wantwindow
  243.       UBYTE  noscript
  244.       UBYTE  post_V34
  245.       UBYTE  post_V38
  246.       UBYTE  fromfile
  247.       UBYTE  keepio
  248.       UBYTE  timerdev1
  249.       UBYTE  timerdev2
  250.       UBYTE  inputdev
  251.       UBYTE  newlock
  252.       UBYTE  execpatch
  253.       UBYTE  cancelsig
  254.       UWORD  pad1
  255.  
  256. ; make sure that mypacket is *ALWAYS* longword aligned !!!
  257.       STRUCT mypacket,68
  258. ; don't change argument order below !!!
  259.       STRUCT buffer,2800
  260.       STRUCT out,100+100
  261.       STRUCT dummy,80+40
  262.       STRUCT in,80+40
  263.       STRUCT cputime,1000
  264.       STRUCT taskstampid,128*4
  265.       STRUCT taskstamps,128*4
  266.       STRUCT usedtime,128*4
  267.       STRUCT ievent,32
  268.       STRUCT outevent,20
  269.       STRUCT inputbuffer,88+40
  270.       STRUCT timerio,40
  271.       STRUCT sampleio,40
  272.       STRUCT repeatbuffer,84+40
  273.       STRUCT hotkeybuf,42
  274.       STRUCT winkeybuf,110
  275.  
  276.     LABEL gb_SIZEOF
  277.  
  278. ; some defines
  279.  
  280. mysigbit    equ    17
  281. maxarg        equ    20
  282.  
  283.         SECTION    Xoper,CODE
  284.  
  285. start        lea    dataarea(pc),a4
  286.         tst.w    detached(a4)        ; already detached ?
  287.         beq    mainprg
  288.         move.l    d0,d2            ; save possible arguments
  289.         move.l    a0,a2
  290.         move.l    a4,a1
  291.         move.w    #(gb_SIZEOF>>2)-1,d1
  292. 1$        clr.l    (a1)+            ; clear bss area
  293.         dbra    d1,1$
  294.         move.l    4,a6
  295.         move.l    a6,sysbase(a4)
  296.         move.l    276(a6),a3
  297.         tst.l    172(a3)
  298.         bne.s    initprg            ; CLI started
  299.         lea    92(a3),a0
  300.         RECALL    WaitPort
  301.         lea    92(a3),a0
  302.         RECALL    GetMsg
  303.         move.l    d0,wbmsg(a4)
  304.         bsr.s    initprg
  305.         RECALL    Forbid
  306.         move.l    wbmsg(a4),a1
  307.         jmp    _LVOReplyMsg(a6)    ; no rc for wb
  308.  
  309. ; some default values (before zero!)
  310.  
  311. initprg        addq.w    #2,mysignal(a4)        ; mask := $20000
  312.         move.w    #500,maxlines+2(a4)
  313.         addq.w    #1,bottomin(a4)
  314.         addq.w    #2,minnumchars(a4)
  315.         move.w    #10,maxhlines(a4)
  316.         move.w    #999,edline(a4)
  317.         addq.b    #5,timeout(a4)
  318.         subq.l    #1,hideon(a4)        ; +headon+tinfo+cmdcli
  319.         subq.l    #1,sorton(a4)        ; +cxstate+iconifyon+propgadon
  320.         subq.w    #1,propupdate(a4)    ; +finfopen
  321.  
  322. ; get arguments and detach program (if started from CLI)
  323.  
  324.         lea    378(a6),a0
  325.         lea    dosname(a4),a1
  326.         RECALL    FindName        ; `open' dos
  327.         move.l    d0,dosbase(a4)
  328.         beq    1$
  329.         move.l    wbmsg(a4),d0
  330.         beq.s    9$            ; not wb start
  331.         bsr    GetToolTypes        ; make cmdline for wb
  332. 9$        bsr    ParseCLI
  333.         CALL    Forbid,sysbase(a4)
  334.         lea    xopcon(a4),a1
  335.         RECALL    FindPort
  336.         move.l    d0,a5
  337.         move.l    a5,d0
  338.         beq.s    4$            ; not found
  339.         move.l    16(a5),a1
  340.         move.l    mysignal(a4),d0
  341.     IFND DEBUG                ; kill for full version only !
  342.         tst.b    bool(a4)
  343.         beq.s    5$            ; wakeup Xoper
  344.  
  345. ; This code tries to remove Xoper from the System in case Xoper 'freezes'
  346. ; or crashes. It works as follows:
  347. ; Xoper leaves the address of its cleanup routine in the UserData field of
  348. ; its Task structure. EXEC's context-restore code leaves the current PC of
  349. ; a task in the first longword of the tasks stack. All we have to do is to
  350. ; copy the address of Xoper's cleanup routine to its stack and to reschedule
  351. ; Xoper (using Signal() in this case).
  352.  
  353.         move.l    54(a1),a0
  354.         btst    #4,297(a6)        ; AttnFlags FPU
  355.         beq.s    6$            ; no FPU
  356.         moveq    #0,d0
  357.         move.b    (a0),d1            ; NULL frame ?
  358.         beq.s    7$
  359.         move.w    (a0),d1            ; frame flag / format word
  360.         lea    110+2(a0),a0        ; offset to fpu regs
  361.         addq.w    #1,d1            ; -1 ?
  362.         beq.s    8$
  363.         lea    12(a0),a0        ; add 3 longs
  364. 8$        move.b    1(a0),d0        ; frame size
  365. 7$        lea    4(a0,d0.w),a0
  366. 6$        move.l    88(a1),d0
  367.         beq.s    4$            ; exit already started
  368.         move.l    d0,0(a0)
  369.         moveq    #-1,d0
  370.     ENDC
  371. 5$        RECALL    Signal
  372. 4$        RECALL    Permit
  373.         move.l    a5,d0
  374.         bne.s    1$
  375.         tst.b    bool(a4)        ; kill request only !
  376.         bne.s    1$
  377.         move.l    dosbase(a4),d6
  378.         exg    d6,a6
  379.         lea    wblock(a4),a2
  380.         moveq    #_LVODupLock,d0
  381.         move.l    0(a2),d1
  382.         bne.s    3$
  383.         moveq    #-2,d2
  384.         move.l    a2,d1
  385.         moveq    #_LVOLock,d0
  386. 3$        jsr    0(a6,d0.w)        ; Lock() or DupLock()
  387.         move.l    d0,0(a2)
  388.         exg    d6,a6
  389.         beq.s    1$
  390.     IFND DEBUG
  391.         tst.l    wbmsg(a4)
  392.         bne.s    2$
  393.         tst.b    wanthold(a4)
  394.         beq.s    0$
  395.         exg    d6,a6            ; show program name
  396.         RECALL    Output
  397.         move.l    d0,d4
  398.         move.l    d4,d1
  399.         lea    verstring(a4),a2
  400.         move.l    a2,d2
  401.         moveq    #10,d3            ; name only
  402.         RECALL    Write
  403.         move.l    d4,d1
  404.         lea    cr(a4),a2
  405.         move.l    a2,d2
  406.         moveq    #1,d3
  407.         RECALL    Write
  408.         exg    d6,a6
  409. 0$        tst.b    keepio(a4)
  410.         beq.s    detach
  411.     ENDC
  412. 2$        bsr    mainprg
  413. 1$        moveq    #0,d0
  414.         rts
  415.  
  416.     IFND DEBUG
  417. detach        move.l    276(a6),a3        ; detach process from CLI
  418.         move.l    172(a3),a3        ; pr_CLI
  419.         adda.l    a3,a3
  420.         adda.l    a3,a3
  421.         lea    60(a3),a3        ; cli_Module
  422.         moveq    #24,d5
  423.         move.l    0(a3),a0
  424. 5$        adda.l    a0,a0            ; count segments
  425.         adda.l    a0,a0
  426.         addq.l    #8,d5
  427.         move.l    0(a0),d0
  428.         move.l    d0,a0
  429.         bne.s    5$
  430.         move.l    d5,d0            ; get memory for seglist
  431.         moveq    #1,d1
  432.         swap    d1
  433.         RECALL    AllocMem
  434.         move.l    d0,a2
  435.         move.l    a2,d0
  436.         beq.s    2$            ; no memory !
  437.         lea    16(a2),a1
  438.         move.l    0(a3),a0
  439. 4$        adda.l    a0,a0            ; setup memlist
  440.         adda.l    a0,a0
  441.         move.l    -(a0),d0
  442.         move.l    a0,(a1)+        ; hunk address
  443.         move.l    d0,(a1)+        ; hunk length
  444.         addq.w    #1,14(a2)        ; one new entry
  445.         move.l    4(a0),d0
  446.         move.l    d0,a0
  447.         bne.s    4$
  448.         RECALL    Forbid            ; create process
  449.         exg    d6,a6
  450.         lea    newname(a4),a1
  451.         move.l    a1,d1
  452.         moveq    #0,d2
  453.         move.l    0(a3),d3
  454.         moveq    #(4096>>6),d4
  455.         lsl.w    #6,d4
  456.         RECALL    CreateProc
  457.         move.l    d0,a5
  458.         move.l    a5,d0
  459.         exg    d6,a6
  460.         beq.s    3$            ; failed !
  461.         lea    -92+74(a5),a0
  462.         move.l    a2,a1            ; add memlist to tc_MemEntry
  463.         RECALL    AddTail
  464.         clr.l    0(a3)            ; no unloading by the shell
  465. 3$        pea    _LVOPermit(a6)
  466.         move.l    a5,d0
  467.         bne.s    1$            ; all ok
  468.         move.l    a2,a1
  469.         move.l    d5,d0
  470.         RECALL    FreeMem            ; free memory
  471. 2$        exg    d6,a6
  472.         move.l    wblock(a4),d1
  473.         RECALL    UnLock
  474.         exg    d6,a6
  475. 1$        clr.w    detached(a4)        ; indicate detaching
  476.         moveq    #0,d0
  477.         rts                ; drop into Permit() :-)
  478.     ENDC
  479.  
  480. ; d0 - wbmsg
  481.  
  482. _LVOGetDiskObject    equ    -78
  483. _LVOFreeDiskObject    equ    -90
  484.  
  485. GetToolTypes    move.l    d0,a0
  486.         lea    buffer+100(a4),a2
  487.         move.l    36(a0),a3        ; sm_ArgList
  488.         move.l    28(a0),d0
  489.         subq.l    #1,d0            ; sm_NumArgs == 1 ?
  490.         beq.s    7$
  491.         addq.w    #8,a3            ; project icon
  492. 7$        move.l    0(a3),wblock(a4)
  493.         lea    icnname(a4),a1
  494.         moveq    #33,d0
  495.         RECALL    OpenLibrary
  496.         move.l    d0,d6
  497.         beq.s    1$            ; no icon library ?!
  498.         move.l    (a3)+,d1
  499.         CALL    CurrentDir,dosbase(a4)    ; set wa_Lock
  500.         move.l    d0,d5
  501.         move.l    0(a3),a0
  502.         CALL    GetDiskObject,d6
  503.         move.l    d0,d4
  504.         beq.s    2$            ; no icon !?
  505.         move.l    d4,a3
  506.         move.l    54(a3),a3        ; do_ToolTypes
  507.         move.l    0(a3),d0
  508.         beq.s    3$
  509. 6$        move.l    d0,a0
  510.         cmp.b    #'A',(a0)
  511.         bcs.s    4$            ; skip < A
  512.         cmp.b    #'z'+1,(a0)
  513.         bcc.s    4$            ; skip > z
  514.         cmp.b    #'Z'+1,(a0)
  515.         bcs.s    5$            ; ok < Z
  516.         cmp.b    #'a',(a0)
  517.         bcs.s    4$            ; skip < a
  518. 5$        move.b    (a0)+,(a2)+        ; copy value
  519.         bne.s    5$
  520.         move.b    #' ',-1(a2)
  521. 4$        move.l    (a3)+,d0
  522.         bne.s    6$
  523. 3$        move.l    d4,a0
  524.         RECALL    FreeDiskObject        ; free icon
  525. 2$        move.l    d5,d1
  526.         CALL    CurrentDir,dosbase(a4)    ; set old lock
  527.         move.l    d6,a1
  528.         CALL    CloseLibrary,sysbase(a4) ; close icon lib
  529. 1$        move.b    #10,(a2)+
  530.         move.l    a2,d2
  531.         lea    buffer+100(a4),a2
  532.         sub.l    a2,d2
  533.         rts
  534.  
  535. ParseCLI    lea    buffer(a4),a1
  536.         subq.w    #1,d2
  537.         move.l    a1,a0
  538. 1$        move.b    (a2)+,(a0)+        ; copy line to a `safe' place
  539.         dbra    d2,1$
  540.         clr.b    -(a0)
  541.         lea    out(a4),a2
  542.         moveq    #0,d2
  543.  
  544. ; a1 - pointer into command line
  545. ; d2 - argc
  546. ; a2 - argv
  547.  
  548. ParseArg    bsr.s    GetNext            ; search argument
  549.         bmi.s    doquote            ; quotation sign
  550.         beq.s    dosemi            ; commentary stops all
  551.         bcs.s    ParseArg        ; separation sign
  552.         lea    -1(a1),a0        ; argument start
  553.         bsr.s    BumpArgV        ; argc+1 & ptr to argv
  554. build_2        bsr.s    GetNext            ; search separation sign
  555.         beq.s    dosemi            ; commentary stops all
  556.         bcc.s    build_2            ; no separation sign
  557.         clr.b    -1(a1)            ; mark end
  558.         bra.s    ParseArg        ; continue search
  559.  
  560. doquote        move.l    a1,a0            ; argument start
  561.         bsr.s    BumpArgV        ; argc+1 & ptr to argv
  562. quote_2        bsr.s    GetNext            ; search quotation sign
  563.         bpl.s    quote_2            ; no quotation sign
  564.         clr.b    -1(a1)            ; mark end
  565. quote_3        bsr.s    GetNext            ; search sepaartion sign
  566.         beq.s    dosemi            ; commentary stops all
  567.         bcc.s    quote_3            ; no separation sign
  568.         bra.s    ParseArg        ; continue search
  569.  
  570. dosemi        clr.b    -(a1)            ; delete semicolon
  571.         bra.s    ParseArg        ; go on
  572.  
  573. BumpArgV    cmp.w    #maxarg,d2        ; max argc reached ?
  574.         bcc.s    1$
  575.         move.l    a0,(a2)+        ; store argptr
  576.         addq.w    #1,d2            ; increment argc
  577. 1$        rts
  578.  
  579. GetNext        move.b    (a1)+,d0        ; test character
  580.         beq.s    BuildRdy
  581.         moveq    #-3,d1            ; N=1,Z=0,C=0 -> quotation
  582.         cmp.b    #'"',d0
  583.         beq.s    1$
  584.         moveq    #-2,d1            ; N=0,Z=1,C=1 -> semicolon
  585.         cmp.b    #';',d0
  586.         beq.s    1$
  587.         moveq    #-1,d1            ; N=0,Z=0,C=1 -> separation
  588.         cmp.b    #'=',d0
  589.         beq.s    1$
  590.         cmp.b    #' ',d0
  591.         beq.s    1$
  592.         cmp.b    #9,d0
  593.         beq.s    1$
  594.         moveq    #0,d1            ; N=0,Z=0,C=0 -> others
  595. 1$        addq.l    #2,d1            ; set flags ( see above )
  596.         rts
  597.  
  598. ; evalute argument vector
  599.  
  600. BuildRdy    addq.w    #4,sp            ; set correct return address
  601.         move.b    d2,entries(a4)
  602.         tst.l    wbmsg(a4)        ; workbench ?
  603.         bne.s    8$
  604.         lea    arghelp(a4),a0        ; help ?
  605.         bsr    findarg
  606.         bne.s    8$
  607.         CALL    Output,dosbase(a4)
  608.         move.l    d0,d1
  609.         lea    template(a4),a2
  610.         move.l    a2,d2
  611.         moveq    #argcmd-template-1,d3
  612.         RECALL    Write
  613.         RECALL    Input
  614.         move.l    d0,d1
  615.         lea    buffer+100(a4),a2
  616.         move.l    a2,d2
  617.         moveq    #80,d3
  618.         RECALL    Read
  619.         move.l    d0,d2
  620.         bne    ParseCLI        ; check input
  621.  
  622. 8$        lea    argcxpop(a4),a0        ; popup ?
  623.         bsr    findarg
  624.         bne.s    7$
  625.         bsr    nextarg
  626.         beq.s    7$
  627.         lea    argcxyes(a4),a0
  628.         bsr    strcmp
  629.         sne    wanthold(a4)
  630.  
  631. 7$        lea    argcxkey(a4),a0        ; new popkey ?
  632.         bsr.s    findarg
  633.         bne.s    6$
  634.         bsr.s    nextarg
  635.         bne.s    5$
  636. 6$        lea    defhotkey(a4),a1
  637. 5$        lea    hotkeybuf(a4),a0
  638.         moveq    #39,d0
  639. 4$        move.b    (a1)+,(a0)+        ; copy hotkey description
  640.         dbeq    d0,4$
  641.         clr.b    (a0)
  642.  
  643.         lea    argcxpri(a4),a0
  644.         bsr.s    findarg
  645.         bne.s    3$
  646.         bsr.s    nextarg
  647.         beq.s    3$
  648.         move.l    a1,a0
  649.         bsr    getnum
  650.         move.b    d2,newbroker+18(a4)    ; nb_Pri
  651.  
  652. 3$        lea    argnoscript(a4),a0    ; skip scriptfile ?
  653.         bsr.s    findarg
  654.         seq    noscript(a4)
  655.  
  656.         lea    argkeepio(a4),a0    ; detach ?
  657.         bsr.s    findarg
  658.         seq    keepio(a4)
  659.  
  660.         lea    argcmd(a4),a0        ; defaultcmd ?
  661.         bsr.s    findarg
  662.         bne.s    2$
  663.         bsr.s    nextarg
  664.         beq.s    2$
  665.         move.b    (a1),d2            ; first char
  666.         lea    argkill(a4),a0
  667.         bsr    strcmp
  668.         bne.s    1$
  669.         st    bool(a4)        ; kill
  670. 2$        moveq    #'t',d2            ; display default to tasks
  671. 1$        lsl.w    #8,d2
  672.         or.w    #10,d2            ; LF
  673.         move.w    d2,in(a4)
  674.         rts
  675.  
  676. findarg        move.b    entries(a4),d2        ; search argument
  677.         lea    out(a4),a2
  678. 2$        subq.b    #1,d2
  679.         bcs.s    1$
  680.         move.l    (a2)+,a1
  681.         bsr    strcmp            ; compare it
  682.         bne.s    2$
  683. 1$        rts
  684.  
  685. nextarg        move.l    (a2),a1            ; make sure ptr is valid
  686.         move.l    a1,d1
  687.         rts
  688.  
  689. ; real main entry (wb and detached)
  690.  
  691. mainprg        move.l    sp,savesp(a4)
  692.         move.l    sysbase(a4),a6
  693.         move.w    20(a6),d0        ; LIB_VERSION
  694.         sub.w    #36,d0
  695.         bcs.s    10$
  696.         st    post_V34(a4)        ; Kick2.0+
  697.         subq.w    #3,d0
  698.         scc    post_V38(a4)        ; Kick3.0+
  699.         move.w    #imagesize,d0
  700.         move.l    image+10(a4),a0
  701. 11$        not.l    (a0)+            ; reverse iconify image
  702.         dbra    d0,11$
  703. 10$        move.l    304(a6),OldTrap(a4)    ; original EXEC Trap-Handler
  704.         move.l    276(a6),a0
  705.         move.l    a0,mytask(a4)
  706.         move.l    50(a0),OldProcTrap(a4)    ; original AmigaDOS Trap-Handler
  707.         lea    stopall(pc),a1
  708.         move.l    a1,88(a0)        ; leave a message for 'Kill Xoper'
  709.         move.l    184(a0),oldprwin(a4)
  710.         moveq    #-1,d0            ; disable the 'please insert'
  711.         move.l    d0,184(a0)        ; requester
  712.  
  713.         lea    div68000(pc),a0        ; set processor dependent
  714.         btst    #1,297(a6)
  715.         beq.s    9$
  716.         lea    div68020(pc),a0
  717. 9$        move.l    a0,div32(a4)        ; division function!
  718.  
  719.         lea    350(a6),a0        ; necessary libs & devs
  720.         lea    conname(a4),a1
  721.         RECALL    FindName
  722.         move.l    d0,condev(a4)
  723.         lea    378(a6),a0
  724.         lea    gfxname(a4),a1
  725.         RECALL    FindName
  726.         move.l    d0,gfxbase(a4)
  727.         lea    378(a6),a0
  728.         lea    intname(a4),a1
  729.         RECALL    FindName
  730.         move.l    d0,intuibase(a4)
  731.         move.l    d0,a0
  732.         move.l    56(a0),a0        ; ib_ActiveScreen
  733.         move.w    12(a0),d0        ; sc_Width
  734.         add.w    d0,window_l(a4)
  735.         move.b    30(a0),d0        ; sc_Barheight
  736.         add.b    d0,window_l+3(a4)
  737.         sub.b    d0,window_w+3(a4)
  738.  
  739.         bsr    gettdtasks
  740.  
  741.         bsr    OpenLibsV37        ; kick 2.0+ libraries
  742.  
  743.         bsr    OpenDevs
  744.         beq    stopall            ; failure
  745.  
  746. ;install a counter for PORT-Interrupts
  747.         lea    iocounter(a4),a1
  748.         move.l    a4,14(a1)
  749.         moveq    #3,d0
  750.         RECALL    AddIntServer
  751.  
  752. ;install a counter to determine the amount of cpu-time each task uses.
  753.         RECALL    Forbid
  754.         moveq    #_LVOSwitch,d0
  755.         lea    myswitch(pc),a0
  756.         exg.l    d0,a0
  757.         move.l    a6,a1
  758.         RECALL    SetFunction
  759.         move.l    d0,OldSwitch(a4)
  760.         lea    myaddtask(pc),a0
  761.         move.l    a0,d0
  762.         move.w    #_LVOAddTask,a0
  763.         move.l    a6,a1
  764.         RECALL    SetFunction
  765.         move.l    d0,OldAddTask(a4)
  766.         RECALL    Permit
  767.         st    execpatch(a4)
  768.  
  769. ;create idle-killer
  770.         moveq    #$40,d0
  771.         lsl.w    #2,d0            ; 256
  772.         moveq    #-128,d1        ; Pri
  773.         lea    kidlename(a4),a0    ; Name
  774.         lea    killidle(pc),a1        ; Code
  775.         bsr    CreateTask
  776.         move.l    d0,idletask(a4)
  777.         beq    stopall
  778.  
  779. ;prepare screen tags
  780.         moveq    #-1,d0
  781.         RECALL    AllocSignal
  782.         move.b    d0,nspubsig+7(a4)
  783.         blt    stopall
  784.  
  785. ;install hotkeys
  786.         moveq    #mysigbit,d0
  787.         RECALL    AllocSignal
  788.         bsr    installh
  789.         beq    stopall
  790.  
  791. ;set our `real' directory - remember old one
  792.         move.l    wblock(a4),d1
  793.         CALL    CurrentDir,dosbase(a4)
  794.         move.l    d0,wblock(a4)
  795.         st    newlock(a4)
  796.  
  797.         tst.b    noscript(a4)        ; process script?
  798.         bne    nostartup
  799.  
  800. ;attempt to open a startup script
  801.         lea    buffer+2400(a4),a5
  802.         lea    startupname(a4),a0    ; 'ENV:Xoper.Startup'
  803.         move.l    a5,a1
  804. 6$        move.b    (a0)+,(a1)+        ; copy string
  805.         bne.s    6$
  806.         moveq    #4,d1
  807.         add.l    a5,d1
  808.         move.l    #1005,d2
  809.         RECALL    Open            ; 'Xoper.startup'
  810.         move.l    d0,d4
  811.         bne.s    5$
  812.         move.l    a5,d1
  813.         RECALL    Open            ; 'ENV:Xoper.Startup'
  814.         move.l    d0,d4
  815.         bne.s    5$
  816.         moveq    #2,d1
  817.         move.b    #'S',0(a5,d1.w)
  818.         add.l    a5,d1
  819.         RECALL    Open            ; 'S:Xoper.startup'
  820.         move.l    d0,d4
  821.         beq.s    nostartup
  822. 5$        move.l    d4,d1
  823.         move.l    a5,d2
  824.         moveq    #(2400>>5),d3
  825.         lsl.w    #5,d3
  826.         RECALL    Read            ; read file at once
  827.         move.l    d0,d3
  828.         move.l    d4,d1
  829.         RECALL    Close            ; close it
  830.         move.l    d3,d0
  831.         addq.l    #1,d0
  832.         beq.s    nostartup        ; read error !
  833.         st    fromfile(a4)
  834. 4$        lea    dummy(a4),a0
  835.         move.l    a0,a2
  836.         lea    80+40-1(a0),a1
  837.         moveq    #10,d1
  838. 3$        move.b    (a5)+,d0        ; copy line to buffer
  839.         move.b    d0,(a0)+
  840.         beq.s    2$            ; NUL
  841.         sub.b    d1,d0
  842.         beq.s    2$            ; LF
  843.         subq.b    #3,d0
  844.         beq.s    2$            ; CR
  845.         cmpa.l    a1,a0
  846.         bcs.s    3$            ; buffer full ?
  847. 2$        move.l    a0,d0
  848.         sub.l    a2,d0            ; length of an input line
  849.         sub.l    d0,d3
  850.         move.l    a5,-(sp)
  851.         move.l    d3,-(sp)
  852.         bsr    cli             ; execute the script as if typed in
  853.         move.l    (sp)+,d3
  854.         move.l    (sp)+,a5
  855.         bgt.s    4$            ; still chars left !
  856.         clr.b    fromfile(a4)
  857.  
  858. nostartup    tst.b    wanthold(a4)        ; background task ?
  859.         bne    instback
  860.  
  861. ; This code just opens a Window. Position and size are
  862. ; taken from window_l,window_t,window_w,window_h.
  863.  
  864. restart        move.l    intuibase(a4),a6
  865.         lea    setupwindow(pc),a0
  866.         tst.b    ownscreen(a4)
  867.         beq.s    1$
  868.         clr.b    ownscreen(a4)
  869.         lea    createscreen(pc),a0
  870. 1$        jsr    0(a0)            ; screen and/or window
  871.         move.l    mytask(a4),a0
  872.         clr.l    26(a0)            ; clear 'spurious' signals
  873.         clr.l    ptr(a4)
  874.         tst.b    gotguru(a4)
  875.         beq.s    2$
  876.         bsr    showguru
  877.         clr.b    gotguru(a4)
  878. 2$        bra    processmsgs
  879.  
  880. gettdtasks    lea    350(a6),a0        ; a6 - SysBase
  881.         lea    tdname(a4),a1
  882.         RECALL    FindName
  883.         beq.s    1$
  884.         move.l    d0,a0
  885.         lea    36(a0),a0
  886.         lea    tdtasks(a4),a1
  887.         moveq    #3,d1
  888. 3$        move.l    (a0)+,d0
  889.         beq.s    2$
  890.         exg.l    d0,a1
  891.         move.l    16(a1),a1
  892.         exg.l    d0,a1
  893. 2$        move.l    d0,(a1)+
  894.         dbra    d1,3$
  895. 1$        rts
  896.  
  897. OpenLibsV37    lea    wbname(a4),a1        ; open 'workbench.library'
  898.         moveq    #wbbase,d2
  899.         bsr.s    1$
  900.         lea    cxname(a4),a1        ; open 'commodities.library'
  901.         moveq    #cxbase,d2
  902. 1$        moveq    #37,d0
  903.         RECALL    OpenLibrary
  904.         move.l    d0,0(a4,d2.w)        ; store libbase
  905. r_t_s        rts
  906.  
  907. OpenDevs    moveq    #0,d2
  908.         RECALL    Forbid
  909.         lea    xopcon(a4),a1        ; rendezvous port
  910.         RECALL    FindPort
  911.         cmp.l    d0,d2
  912.         bne.s    4$            ; port found!
  913. ;        moveq    #0,d0
  914.         lea    xopcon(a4),a0
  915.         bsr    CreatePort        ; new port
  916.         move.l    d0,d2
  917. 4$        RECALL    Permit
  918.         move.l    d2,replyport(a4)
  919.         beq.s    r_t_s            ; no mem or already there
  920.         moveq    #0,d0
  921.         suba.l    a0,a0
  922.         bsr    CreatePort
  923.         move.l    d0,timerio+14(a4)
  924.         beq.s    r_t_s
  925.         move.l    d0,a0
  926.         move.b    15(a0),timersig+1(a4)
  927.         lea    timerio(a4),a1
  928.         lea    timername(a4),a0
  929.         moveq    #1,d0
  930.         moveq    #0,d1
  931.         RECALL    OpenDevice        ; open 'timer.device'
  932.         tst.b    d0
  933.         bne.s    1$
  934.         st    timerdev1(a4)
  935.         tst.b    post_V34(a4)
  936.         beq.s    3$
  937.         lea    newtime(a4),a0
  938.         CALL    ReadEClock,timerio+20(a4)
  939.         move.l    newtime+4(a4),lasttime(a4)
  940.         lsr.l    #8,d0
  941.         bra.s    2$
  942. 3$        moveq    #0,d0
  943.         suba.l    a0,a0    
  944.         bsr    CreatePort
  945.         move.l    d0,sampleio+14(a4)
  946.         beq.s    1$
  947.         lea    sampleio(a4),a1
  948.         lea    timername(a4),a0
  949.         moveq    #0,d0
  950.         moveq    #0,d1
  951.         RECALL    OpenDevice        ; open 'timer.device'
  952.         tst.b    d0
  953.         bne.s    1$
  954.         st    timerdev2(a4)
  955.         lea    sampleio(a4),a1
  956.         move.l    #3599999,32(a1)
  957.         move.w    #9,28(a1)
  958.         RECALL    SendIO
  959.         move.l    #3906,d0
  960. 2$        move.l    d0,timerticks(a4)
  961.         bsr.s    starttasktimer
  962.         rts
  963.  
  964. 1$        moveq    #0,d0            ; return NULL
  965.         rts
  966.  
  967. starttasktimer    lea    tsecs(a4),a0
  968.         lea    tmics(a4),a1
  969.         CALL    CurrentTime,intuibase(a4)
  970.         bsr    getaskdat2        ; returns SysBase in a6 !
  971.         move.l    tsecs(a4),d0
  972.         lea    taskstampid(a4),a0
  973.         lea    taskstamps(a4),a1
  974.         lea    usedtime(a4),a2
  975.         moveq    #0,d1
  976. 2$        subq.b    #1,d5
  977.         bcs.s    1$
  978.         lea    -16(a5),a5
  979.         move.l    0(a5),(a0)+
  980.         move.l    d0,(a1)+
  981.         clr.l    (a2)+
  982.         addq.w    #1,d1
  983.         cmp.w    #128,d1
  984.         bcs.s    2$
  985. 1$        move.w    d1,numtaskstimed(a4)    ; Z-Flag != 0
  986.         rts
  987.  
  988. ; exit program 
  989.  
  990. stopall        st    waitexit(a4)        ; wait until pubscr freed
  991.         tst.b    appicn(a4)
  992.         beq.s    exitall
  993.         move.l    wnptr(a4),a0        ; remove appicon here
  994.         CALL    RemoveAppIcon,wbbase(a4)
  995.         clr.l    wnptr(a4)
  996.  
  997. exitall        tst.b    ownscreen(a4)
  998.         beq.s    9$            ; no screen == no pub screen !
  999.         st    wantexit(a4)
  1000.         bsr    SetPubStatus
  1001.         beq.s    stopall-2        ; pubscreen still used
  1002.  
  1003. 9$        move.l    mytask(a4),a2
  1004.         clr.l    88(a2)            ; disable killing !
  1005.  
  1006.         moveq    #1,d0
  1007.         bsr    CloseGUI        ; close screen & window
  1008.  
  1009.         bsr    killpage
  1010.         bsr    freeblank
  1011.         bsr    killhistory
  1012.         bsr    freehidmem
  1013.         bsr    freealias
  1014.         bsr    clrfkeys
  1015.  
  1016. 8$        move.l    stplist(a4),a3
  1017.         tst.l    0(a3)
  1018.         beq.s    7$
  1019.         move.l    a3,d0
  1020.         bsr    waok
  1021.         bra.s    8$
  1022.  
  1023. 7$        bsr    remtraps
  1024.  
  1025.         move.l    dosbase(a4),a6
  1026.         move.l    wblock(a4),d1
  1027.         tst.b    newlock(a4)
  1028.         beq.s    62$
  1029.         RECALL    CurrentDir
  1030.         move.l    d0,d1
  1031. 62$        RECALL    UnLock
  1032.  
  1033.         move.l    sysbase(a4),a6
  1034.  
  1035.         moveq    #0,d0
  1036.         move.b    nspubsig+7(a4),d0
  1037.         ble.s    61$
  1038.         RECALL    FreeSignal
  1039. 61$        bsr    removeh
  1040.         moveq    #mysigbit,d0
  1041.         RECALL    FreeSignal
  1042.  
  1043.         move.l    idletask(a4),d0
  1044.         beq.s    6$
  1045.         move.l    d0,a1
  1046.         RECALL    RemTask
  1047.  
  1048. 6$        tst.b    execpatch(a4)
  1049.         beq    0$            ; not installed
  1050.  
  1051.         st    waitexit(a4)
  1052.         st    bool(a4)
  1053.  
  1054. 5$        tst.b    bool(a4)
  1055.         beq.s    2$            ; exec patches removed !
  1056.         RECALL    Forbid
  1057.         tst.b    patchmode(a4)
  1058.         beq.s    4$            ; don't check vectors
  1059.         lea    myswitch(pc),a0
  1060.         cmp.l    _LVOSwitch+2(a6),a0
  1061.         bne.s    3$
  1062.         lea    myaddtask(pc),a0
  1063.         cmp.l    _LVOAddTask+2(a6),a0
  1064.         bne.s    3$
  1065. 4$        move.l    OldSwitch(a4),d0
  1066.         move.w    #_LVOSwitch,a0
  1067.         move.l    a6,a1
  1068.         RECALL    SetFunction
  1069.         move.l    OldAddTask(a4),d0
  1070.         move.w    #_LVOAddTask,a0
  1071.         move.l    a6,a1
  1072.         RECALL    SetFunction
  1073.         clr.b    bool(a4)
  1074. 3$        RECALL    Permit
  1075.  
  1076. 2$        bsr    snoopend        ; mem trace
  1077.         bsr    traceend        ; dos trace
  1078.  
  1079.         move.b    bool(a4),d0        ; exec -> switch,addtask
  1080.         add.b    msnoop(a4),d0        ; exec -> memory
  1081.         add.b    DosTable+5(a4),d0    ; dos  -> open
  1082.         add.b    DosTable+25(a4),d0    ; dos  -> lock
  1083.         beq.s    1$            ; zero == all removed
  1084.         moveq    #0,d0
  1085.         move.l    mysignal(a4),d1
  1086.         CALL    SetSignal,sysbase(a4)
  1087.         st    pcheck(a4)        ; enable checking ...
  1088.         move.l    mysignal(a4),d0
  1089.         RECALL    Wait            ; wait for intr signal
  1090.         bra.s    5$            ; try again ...
  1091.  
  1092. 1$        lea    iocounter(a4),a1
  1093.         moveq    #3,d0
  1094.         RECALL    RemIntServer
  1095.  
  1096. 0$        bsr    CloseDevs
  1097.         bsr    CloseLibsV37        ; close Kick 2.0+ libraries
  1098.  
  1099.         move.l    mytask(a4),a2
  1100.         move.l    oldprwin(a4),184(a2)    ; reset to old value
  1101.  
  1102.         move.l    savesp(a4),sp        ; restore sp
  1103.         rts
  1104.  
  1105. CloseLibsV37    move.l    sysbase(a4),a6
  1106.         move.l    cxbase(a4),a1        ; commodities base
  1107.         bsr.s    2$
  1108.         move.l    wbbase(a4),a1        ; workbench base
  1109. 2$        move.l    a1,d0
  1110.         beq.s    1$            ; no lib
  1111.         RECALL    CloseLibrary
  1112. 1$        rts
  1113.  
  1114. CloseDevs    tst.b    timerdev2(a4)        ; free timer stuff
  1115.         beq.s    4$
  1116.         lea    sampleio(a4),a1
  1117.         CALL    AbortIO,sysbase(a4)
  1118.         lea    sampleio(a4),a1
  1119.         RECALL    CloseDevice
  1120. 4$        move.l    sampleio+14(a4),d0
  1121.         bsr.s    2$            ; free port
  1122.         tst.b    timerdev1(a4)
  1123.         beq.s    3$
  1124.         bsr    stoptimer
  1125.         lea     timerio(a4),a1
  1126.         CALL    CloseDevice,sysbase(a4)
  1127. 3$        move.l    timerio+14(a4),d0
  1128.         bsr    2$            ; free port
  1129.         move.l    replyport(a4),d0
  1130. 2$        beq.s    1$
  1131.         bsr    DeletePort
  1132. 1$        rts
  1133.  
  1134. ;show a list. The string entered from keyboard is stored
  1135. ;in 'in'. Every character is interpreted as one command
  1136. ;i.e. 'rip' means 'resources'+'interrupts'+'ports'.
  1137. ;search the command to be executed. If none is found,
  1138. ;show a help message
  1139.  
  1140. showwhat    tst.b    fromfile(a4)
  1141.         bne.s    nomore
  1142.         move.w    cmdptr(a4),d7
  1143.  
  1144. input        lea    in(a4),a0
  1145.         move.b    0(a0,d7.w),d0
  1146.         beq.s    endshow
  1147.         addq.w    #1,d7
  1148.         cmpi.b    #' ',d0
  1149.         bne.s    i1
  1150.         bsr.s    testifend
  1151.         beq.s    endshow
  1152.         move.w    d2,cmdptr(a4)
  1153.         bra.s    endshow2
  1154.  
  1155. i1        cmpi.b    #10,d0
  1156.         beq.s    endshow
  1157.         or.b    #32,d0
  1158.         cmpi.b    #'q',d0
  1159.         beq    quithold
  1160.         lea    params(a4),a0
  1161.         moveq    #parmnum-1,d1
  1162. i2        cmp.b    0(a0,d1.w),d0
  1163.         beq.s    foundp
  1164.         dbra    d1,i2
  1165.         move.w    #usetxt,d0
  1166.         bsr    putnamw
  1167.         bra.s    endshow
  1168.  
  1169. foundp        lea    subs(pc),a0
  1170.         lsl.w    #2,d1
  1171.         jsr    0(a0,d1.w)
  1172.         bsr.s    testifend
  1173.         beq.s    input
  1174.         bsr    newline
  1175.         bra.s    input
  1176.  
  1177. endshow        clr.w    cmdptr(a4)
  1178. endshow2    bsr    starttimer
  1179. nomore        tst.b    fromfile(a4)
  1180.         bne.s    1$
  1181.         clr.l    lastprinted(a4)
  1182.         bsr    blastout
  1183. 1$        rts
  1184.  
  1185. testifend    lea    in(a4),a0
  1186.         lea    0(a0,d7.w),a0
  1187.         move.w    d7,d2
  1188. 2$        move.b    (a0)+,d0
  1189.         beq.s    1$
  1190.         cmpi.b    #' ',d0
  1191.         bne.s    3$
  1192.         addq.w    #1,d2
  1193.         bra.s    2$
  1194. 3$        cmpi.b    #10,d0
  1195. 1$        rts
  1196.  
  1197. ;get the string from inputbuffer; search and execute
  1198. ;the command, if any.
  1199.  
  1200. cli        lea    dummy(a4),a0
  1201.         subq.w    #1,d0
  1202. cl2        subq.w    #1,d0
  1203.         bmi.s    cl1
  1204.         cmp.b    #' ',0(a0,d0.w)
  1205.         beq.s    cl2
  1206. cl1        addq.w    #1,d0
  1207.         move.b    #10,0(a0,d0.w)
  1208.         bsr    kllblnks        ; remove trailing blanks ... !
  1209.         cmpi.b    #10,0(a0)
  1210.         beq    showwhat
  1211.         cmpi.b    #';',0(a0)
  1212.         beq.s    nomore
  1213.  
  1214.         bsr.s    findcmd
  1215.         tst.l    d2
  1216.         bpl.s    okcmd            ; cmd found
  1217.         bsr.s    findalias
  1218.         tst.l    d2
  1219.         bmi.s    nm0            ; no alias
  1220. okcmd        clr.w    procnum(a4)
  1221.         adda.w    d1,a0
  1222.         bsr    kllblnks
  1223.         lea    cmdaddr(pc),a1
  1224.         lsl.w    #2,d2
  1225.         jsr     0(a1,d2.w)
  1226.         bra.s    nomore
  1227.  
  1228. nm0        moveq    #10,d1            ; LineFeed
  1229.         lea    in(a4),a1
  1230.         lea    buffer(a4),a2
  1231.         movem.l    a1/a2,-(sp)        ; store for later use
  1232. nm1        move.b    (a1),(a2)+        ; in -> buffer
  1233.         cmp.b    (a1)+,d1        ; LF ?
  1234.         bne.s    nm1
  1235.         move.l    (sp)+,a1
  1236. nm2        move.b    (a0),(a1)+        ; cmd -> in
  1237.         cmp.b    (a0)+,d1        ; LF ?
  1238.         bne.s    nm2
  1239.         move.l    (sp)+,a1
  1240.         lea    dummy(a4),a2
  1241. nm3        move.b    (a1),(a2)+        ; buffer -> dummy
  1242.         cmp.b    (a1)+,d1        ; LF ?
  1243.         bne.s    nm3
  1244.         clr.w    cmdptr(a4)
  1245.         bra    showwhat
  1246.  
  1247. findcmd        move.l    a0,-(sp)
  1248.         bsr    strbuf
  1249.         lea    commds(a4),a2
  1250.         moveq    #0,d2
  1251. 1$        lea    buffer(a4),a0
  1252.         move.l    a2,a1
  1253.         bsr    strcmp
  1254.         beq.s    3$
  1255. 2$        tst.b    (a2)+
  1256.         bne.s    2$
  1257.         addq.w    #1,d2
  1258.         cmp.w    #cmdnum,d2
  1259.         bne.s    1$
  1260.         moveq    #-1,d2
  1261. 3$        move.l    (sp)+,a0
  1262.         rts
  1263.  
  1264. findalias    move.l    a0,-(sp)
  1265.         lea    aliaslist(a4),a2
  1266. 1$        move.l    0(a2),d2
  1267.         move.l    d2,a2
  1268.         beq.s    3$
  1269.         lea    buffer(a4),a0
  1270.         lea    5(a2),a1
  1271.         move.b    4(a2),d2
  1272.         ext.w    d2
  1273.         ext.l    d2
  1274.         bsr    strcmp
  1275.         beq.s    4$
  1276.         bra.s    1$
  1277. 3$        moveq    #-1,d2
  1278. 4$        move.l    (sp)+,a0
  1279.         rts
  1280.  
  1281. subs        bra    showtask
  1282.         bra    showaddr
  1283.         bra    showdevs
  1284.         bra    showlibs
  1285.         bra    showres
  1286.         bra    showresi
  1287.         bra    showmem
  1288.         bra    showprt
  1289.         bra    showint
  1290.         bra    stack
  1291.         bra    clicomm
  1292.         bra    tasktime
  1293.         bra    semaphores
  1294. cmdaddr     bra    settime
  1295.         bra    taskpri
  1296.         bra    info
  1297.         bra    pri
  1298.         bra    flush
  1299.         bra    freeze
  1300.         bra    warm
  1301.         bra    signal
  1302.         bra    break
  1303.         bra    alert
  1304.         bra    lastalert
  1305.         bra    instback
  1306.         bra    exitall
  1307.         bra    clear
  1308.         bra    cancel
  1309.         bra    taskports
  1310.         bra    hunks
  1311.         bra    devices
  1312.         bra    openlib
  1313.         bra    closelib
  1314.         bra    currentdir
  1315.         bra    cd
  1316.         bra    mypri
  1317.         bra    openfiles
  1318.         bra    locks
  1319.         bra    unlock
  1320.         bra    screens
  1321.         bra    windows
  1322.         bra    closescreen
  1323.         bra    closewindow
  1324.         bra    fonts
  1325.         bra    windowfonts
  1326.         bra    lockdrive
  1327.         bra    freedrive
  1328.         bra    capture
  1329.         bra    clrcold
  1330.         bra    clrcool
  1331.         bra    clrwarm
  1332.         bra    snoop
  1333.         bra    usage
  1334.         bra    inputhandler
  1335.         bra    nohead
  1336.         bra    sort
  1337.         bra    hide
  1338.         bra    hidden
  1339.         bra    setwindow
  1340.         bra    cancel
  1341.         bra    icongad
  1342.         bra    historylines
  1343.         bra    historylength
  1344.         bra    showhistory
  1345.         bra    repeatcmd
  1346.         bra    remresident
  1347.         bra    saveoutput
  1348.         bra    killhistory
  1349.         bra    iconbackdrp
  1350.         bra    myfont
  1351.         bra    setfont
  1352.         bra    trapguru
  1353.         bra    outputlines
  1354.         bra    usescreen
  1355.         bra    usewindow
  1356.         bra    usetopaz
  1357.         bra    grabtimerio
  1358.         bra    dchange
  1359.         bra    alias
  1360.         bra    remnode
  1361.         bra    setfkey
  1362.         bra    clicmd
  1363.         bra    taskinfo
  1364.         bra    coldreboot
  1365.         bra    reboot
  1366.         bra    zerotimer
  1367.         bra    propgad
  1368.         bra    iconpos
  1369.         bra    remport
  1370.         bra    remintserver
  1371.         bra    frags
  1372.         bra    tracefiles
  1373.         bra    tracelocks
  1374.         bra    cxhandler
  1375.         bra    cxpopkey
  1376.         bra    pubscreens
  1377.         bra    smartpatch
  1378.         bra    lowmemhandler
  1379.  
  1380. ;------ Task-Structures-----
  1381.  
  1382. tasktime    moveq    #-1,d0
  1383.         bra.s    startask
  1384. showaddr    moveq    #0,d0
  1385.         bra.s    startask
  1386. showtask    moveq    #1,d0
  1387. startask    move.b    d0,tasktyp(a4)
  1388.         bsr    getdevhan
  1389.         tst.b    headon(a4)
  1390.         beq    noheader1
  1391.         move.w    #infoh1,d0
  1392.         bsr    putstrw
  1393.         move.l    sysbase(a4),a6
  1394.         move.w    296(a6),d1        ; AttnFlags
  1395.         move.w    #cpu5,d0
  1396.         btst    #7,d1            ; mc 68060 ?
  1397.         bne.s    cpupr
  1398.         subq.w    #cpu5-cpu4,d0
  1399.         btst    #3,d1            ; mc 68040 ?
  1400.         bne.s    cpupr
  1401.         subq.w    #cpu4-cpu3,d0
  1402.         btst    #2,d1            ; mc 68030 ?
  1403.         bne.s    cpupr
  1404.         subq.w    #cpu3-cpu2,d0
  1405.         btst    #1,d1            ; mc 68020 ?
  1406.         bne.s    cpupr
  1407.         subq.w    #cpu2-cpu1,d0
  1408.         btst    #0,d1            ; mc 68010 ?
  1409.         bne.s    cpupr
  1410.         subq.w    #cpu1-cpu0,d0        ; mc 68000 !
  1411. cpupr        bsr    putstrw
  1412.         move.w    296(a6),d1
  1413.         btst    #3,d1            ; mc 68040 ?
  1414.         beq.s    1$
  1415.         btst    #6,d1            ; mc FPU40 ?
  1416.         beq.s    noFPU
  1417.         moveq    #fpu2-fpu1,d2
  1418.         and.w    #(1<<5)+(1<<4),d1
  1419.         cmp.w    #(1<<5)+(1<<4),d1    ; 68040.library loaded ?
  1420.         sne    d1
  1421.         ext.w    d1
  1422.         and.w    d1,d2
  1423.         add.w    #fpu1,d2        ; set FPU
  1424.         bra.s    fpupr
  1425. 1$        move.w    #fpu1,d2
  1426.         btst    #5,d1            ; mc 68882 ?
  1427.         bne.s    fpupr
  1428.         subq.w    #fpu1-fpu0,d2
  1429.         btst    #4,d1            ; mc 68881 ?
  1430.         beq.s    noFPU
  1431. fpupr        move.w    d2,d0
  1432.         bsr    putstrw
  1433. noFPU        moveq    #20,d1
  1434.         bsr    tab
  1435.         move.w    #infoh3,d0
  1436.         bsr    putstrw
  1437.  
  1438. noheader1    moveq    #1,d5
  1439.         bsr    getaskdat
  1440.         move.l    a5,savedat(a4)
  1441.         bsr    getstdio
  1442.  
  1443.         lea    usedtime(a4),a0
  1444.         moveq    #0,d4
  1445.         moveq    #0,d3
  1446.         move.l    idletask(a4),d2
  1447.         moveq    #0,d1
  1448.         move.b    entries(a4),d1
  1449.         subq.w    #1,d1
  1450. 1$        lea    -16(a5),a5
  1451.         move.l    12(a5),d5
  1452.         add.l    d5,d4
  1453.         move.l    0(a5),d0
  1454.         cmp.l    d0,d2
  1455.         bne.s    2$
  1456.         move.l    d5,d3
  1457. 2$        bsr    gettimeentry
  1458.         add.l    d5,0(a0,d0.w)
  1459.         dbra    d1,1$
  1460.         move.l    d4,maxdisp(a4)
  1461.         sub.l    d3,d4
  1462.         move.l    d4,dispatches(a4)
  1463.  
  1464.         tst.b    headon(a4)
  1465.         beq.s    noheader2
  1466.         move.l    dispatches(a4),d0
  1467.         move.l    maxdisp(a4),d1
  1468.         bsr    prcent
  1469.         bsr    newline
  1470.         move.w    #infoh2,d0
  1471.         bsr    putstrw
  1472.  
  1473. noheader2    move.l    sysbase(a4),a0
  1474.         move.l    284(a0),d0        ; DispCount
  1475.         move.l    oldswitches(a4),d1
  1476.         move.l    d0,oldswitches(a4)
  1477.         sub.l    d1,d0
  1478.         tst.b    headon(a4)
  1479.         beq.s    noheader3
  1480.         mulu    #100,d0
  1481.         move.l    d0,-(sp)
  1482.         lea    secs(a4),a0
  1483.         lea    mics(a4),a1
  1484.         CALL    CurrentTime,intuibase(a4)
  1485.         move.l    secs(a4),d3
  1486.         add.l    d3,d3
  1487.         move.l    d3,d1
  1488.         lsl.l    #2,d3
  1489.         add.l    d1,d3
  1490.         move.l    mics(a4),d0
  1491.         move.l    #100000,d1
  1492.         bsr    div
  1493.         add.l    d0,d3
  1494.         move.l    time10(a4),d1
  1495.         move.l    d3,time10(a4)
  1496.         sub.l    d1,d3
  1497.         move.l    (sp)+,d0
  1498.         move.l    d3,-(sp)
  1499.         move.l    d3,d1
  1500.         bsr    div
  1501.         moveq    #1,d5
  1502.         bsr    putfrac
  1503.  
  1504.         moveq    #20,d1
  1505.         bsr    tab
  1506.         move.w    #infoh7,d0
  1507.         bsr    putstrw
  1508.         move.l    iocount(a4),d0
  1509.         clr.l    iocount(a4)
  1510.         mulu    #100,d0
  1511.         move.l    (sp)+,d3
  1512.         move.l    d3,d1
  1513.         bsr    div
  1514.         moveq    #1,d5
  1515.         bsr    putfrac
  1516.  
  1517.         bsr    newline
  1518.         bsr    newline
  1519.  
  1520. noheader3    lea    t4header(a4),a0
  1521.         tst.b    tasktyp(a4)
  1522.         bmi.s    phedder
  1523.         lea    theader(a4),a0
  1524.         tst.b    tasktyp(a4)
  1525.         bne.s    phedder
  1526.         lea    t2header(a4),a0
  1527.         move.l    sysbase(a4),a6
  1528.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1529.         bne.s    phedder
  1530.         lea    t3header(a4),a0
  1531. phedder     bsr    puthead
  1532.         move.l    savedat(a4),a5
  1533.  
  1534. pt1        tst.b    entries(a4)
  1535.         beq    pt2
  1536.         lea    -16(a5),a5
  1537.         bsr    hideit
  1538.         beq    ptend
  1539.         move.l    0(a5),a3
  1540.         cmp.l    idletask(a4),a3
  1541.         beq    ptend
  1542.         move.l    a3,node(a4)        ; ID = task address
  1543.         move.l    a3,d0
  1544.         bsr    hexa
  1545.         tst.b    tasktyp(a4)
  1546.         ble.s    pt12
  1547.         moveq    #0,d0
  1548.         move.b    8(a3),d0
  1549.         bsr    gettype
  1550.  
  1551. pt12        moveq    #0,d0
  1552.         move.b    9(a5),d0
  1553.         subq.w    #1,d0
  1554.         mulu    #9,d0
  1555.         move.w    #status,d1
  1556.         add.w    d1,d0
  1557.         bsr    putstrw            ; state
  1558.         tst.b    tasktyp(a4)
  1559.         beq.s    pt345
  1560.         bpl    pt13
  1561.  
  1562.         move.l    0(a5),d0        ; for usage !
  1563.         bsr    gettimeentry
  1564.         lea    taskstamps(a4),a0
  1565.         lea    0(a0,d0.w),a0
  1566.         move.l    secs(a4),d0
  1567.         sub.l    0(a0),d0
  1568.         bsr    putstamp
  1569.         bsr    putblank
  1570.         move.l    usedtime-taskstamps(a0),d0
  1571.         move.l    timerticks(a4),d1
  1572.         bsr    div
  1573.         bsr    putstamp
  1574.         moveq    #'.',d0
  1575.         bsr    putchar
  1576.         move.l    d1,d0
  1577.         move.l    timerticks(a4),d1
  1578.         addq.w    #5,d1
  1579.         divu    #10,d1
  1580.         divu    d1,d0
  1581.         or.b    #'0',d0
  1582.         bsr    putchar
  1583.         bsr    putblank
  1584.         bra    pt346
  1585.  
  1586. pt345        move.l    18(a3),d0        ; SigAlloc
  1587.         bsr    hexa
  1588.         move.w    #longnix,d0
  1589.         cmp.b    #4,9(a5)        ; tc_state waiting ?
  1590.         beq.s    pt14
  1591.         bsr    putstrw
  1592.         bra.s    pt15
  1593.  
  1594. pt14        move.l    22(a3),d0        ; SigWait
  1595.         bsr    hexa
  1596. pt15        move.l    26(a3),d0        ; SigRecvd
  1597.         bsr    hexa
  1598.  
  1599.         move.w    #nofpu,d1        ; assume no FPU
  1600.         move.l    sysbase(a4),a6
  1601.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1602.         beq.s    2$
  1603.         move.w    #nullstate,d1        ; assume FPU null-state
  1604. 2$        lea    2$(pc),a1
  1605.         move.l    a1,d0
  1606.         cmp.b    #2,9(a5)        ; tc_state running ?
  1607.         beq.s    pt16            ; can only be xoper itself
  1608.  
  1609.         move.l    54(a3),a1        ; tc_SPReg
  1610.         move.l    0(a1),d0
  1611.  
  1612.         btst    #4,297(a6)        ; AttnFlags FPU
  1613.         beq.s    pt16            ; no FPU
  1614.  
  1615.         move.l    4(a1),d0
  1616.         tst.b    0(a1)            ; NULL frame ?
  1617.         beq.s    pt16            ; yes
  1618.  
  1619.         move.w    (a1),d0            ; frame flag / format word
  1620.         lea    110+2(a1),a1        ; offset for fpu regs
  1621.         addq.w    #1,d0
  1622.         beq.s    1$
  1623.         lea    12(a1),a1        ; 3 more longs
  1624.  
  1625. 1$        moveq    #0,d0
  1626.         move.b    1(a1),d0        ; frame size
  1627.         move.l    4(a1,d0.w),d0        ; pc
  1628.  
  1629.         move.w    #idle,d1
  1630.         cmp.b    #$18,1(a1)        ; mc 68881 idle ?
  1631.         beq.s    pt16
  1632.         addq.w    #busy-idle,d1
  1633.         cmp.b    #$b4,1(a1)        ; mc 68881 busy ?
  1634.         beq.s    pt16
  1635.         addq.w    #dontknow-busy,d1    ; mc 68882 ??
  1636.  
  1637. pt16        bsr    hexa
  1638.  
  1639.         move.l    sysbase(a4),a6
  1640.         btst    #4,297(a6)        ; AttnFlags FPU ?
  1641.         beq.s    pt4
  1642.  
  1643.         move.w    d1,d0            ; fpu state
  1644.         bsr    putstrw
  1645.         bra.s    pt4
  1646.  
  1647. pt13        move.b    10(a5),d3        ; tc_Pri
  1648.         bsr    plusmins
  1649.  
  1650.         move.l    12(a5),d0
  1651.         move.l    dispatches(a4),d1
  1652.         tst.b    useageon(a4)
  1653.         beq.s    pt37
  1654.         move.l    maxdisp(a4),d1
  1655. pt37        bsr    prcent
  1656.  
  1657. pt346        cmpi.b    #13,8(a5)        ; num
  1658.         bne.s    noproc
  1659.         tst.l    172(a3)
  1660.         beq.s    noproc
  1661.         move.b    11(a5),d3
  1662.         bsr    bytedec
  1663.         bra.s    pt4
  1664. noproc        move.w    #nix,d0
  1665.         bsr    putstrw
  1666.  
  1667. pt4        bsr    gettaskname        ; taskname
  1668.  
  1669.         tst.b    tinfo(a4)
  1670.         beq    pt223
  1671.  
  1672.         tst.b    cliexec(a4)        ; display 'real' taskname if
  1673.         beq.s    10$             ; it is a CLI
  1674.         bsr    putblank
  1675.         move.l    4(a5),d0
  1676.         bsr    putstr
  1677.  
  1678. 10$        lea    tdtasks(a4),a1        ; a trackdisk.device ?
  1679.         moveq    #3,d3
  1680. 1$        cmp.l    (a1)+,a3
  1681.         dbeq    d3,1$
  1682.         bne.s    pt224
  1683.  
  1684.         eor.b    #'0'+3,d3        ; print unit#
  1685.         move.b    d3,unitmsg+8(a4)
  1686.         move.w    #unitmsg,d0
  1687.         bsr    putstrw
  1688.  
  1689. pt224        moveq    #0,d3            ; is it a device handler ?
  1690.         lea    buffer+2400(a4),a2
  1691.         lea    200(a2),a1
  1692.  
  1693. 1$        move.l    (a2)+,d0
  1694.         beq.s    pt222
  1695.         move.l    (a1)+,d2
  1696.         cmp.l    0(a5),d0
  1697.         bne.s    1$
  1698.  
  1699. 2$        move.l    #' {',d0        ; print dos devicename
  1700.         bsr    putlongascii
  1701.         move.l    d2,d0
  1702.         bsr    putbcpl
  1703.         move.l    #':}',d0
  1704.         bsr    putlongascii
  1705.  
  1706. pt222        lea    buffer+2160(a4),a1    ; is it a device handler for
  1707.         lea    160(a1),a2        ; some CLI input/output ?
  1708.         moveq    #0,d5
  1709.  
  1710. 3$        move.l    (a1)+,d0
  1711.         beq.s    4$
  1712.         move.w    (a2)+,d2
  1713.         cmp.l    0(a5),d0
  1714.         bne.s    3$
  1715.  
  1716.         tst.w    d5
  1717.         bne.s    5$
  1718.         move.l    #' (',d0        ; print CLI#
  1719.         bsr    putlongascii
  1720.         bra.s    6$
  1721. 5$        move.l    #'& ',d0
  1722.         bsr    putlongascii
  1723. 6$        moveq    #1,d5
  1724.         moveq    #'<',d0
  1725.         tst.w    d2
  1726.         bmi.s    7$
  1727.         moveq    #'>',d0
  1728. 7$        bsr    putchar
  1729.         move.l    #'CLI ',d0
  1730.         bsr    putlongascii
  1731.         moveq    #0,d0
  1732.         move.b    d2,d0
  1733.         moveq    #0,d3
  1734.         bsr    longdec
  1735.         bra.s    3$
  1736.  
  1737. 4$        tst.w    d5
  1738.         beq.s    pt223
  1739.         subq.l    #1,ptr(a4)
  1740.         moveq    #')',d0
  1741.         bsr    putchar
  1742.  
  1743. pt223        bsr    newline
  1744.  
  1745. ptend        subq.b    #1,entries(a4)
  1746.         bra    pt1
  1747. pt2        rts
  1748.  
  1749. getdevhan    tst.b    tinfo(a4)
  1750.         beq.s    4$
  1751.         move.l    a3,-(sp)
  1752.         bsr    devinfo
  1753.         moveq    #49,d3
  1754.         lea    buffer+2400(a4),a2
  1755.         lea    200(a2),a3
  1756. 1$        adda.l    a1,a1
  1757.         adda.l    a1,a1
  1758.         tst.l    4(a1)
  1759.         bne.s    3$
  1760.         move.l    8(a1),d0
  1761.         beq.s    3$
  1762.         moveq    #92,d1
  1763.         sub.l    d1,d0
  1764.         move.l    d0,(a2)+
  1765.         move.l    40(a1),(a3)+
  1766.         subq.w    #1,d3
  1767.         beq.s    2$
  1768. 3$        move.l    0(a1),d0
  1769.         beq.s    2$
  1770.         move.l    d0,a1
  1771.         bra.s    1$
  1772. 2$        clr.l    (a2)+
  1773.         move.l    (sp)+,a3
  1774. 4$        rts
  1775.  
  1776. getstdio    tst.b    tinfo(a4)
  1777.         beq.s    4$
  1778.         move.l    a5,-(sp)
  1779.         lea    buffer+2160(a4),a0
  1780.         lea    160(a0),a1
  1781.         moveq    #0,d3
  1782.         move.b    entries(a4),d3
  1783.         subq.w    #1,d3
  1784.         moveq    #40,d4
  1785. 3$        lea    -16(a5),a5
  1786.         cmpi.b    #13,8(a5)
  1787.         bne.s    1$
  1788.         RECALL    Forbid
  1789.         move.l    0(a5),a3
  1790.         move.l    140(a3),d2        ; pr_TaskNum
  1791.         beq.s    6$
  1792.         move.l    172(a3),d0        ; pr_CLI
  1793.         beq.s    6$
  1794.         move.l    160(a3),d0        ; pr_COS
  1795.         beq.s    2$
  1796.         bsr.s    getstdio2
  1797. 2$        or.w    #$8000,d2
  1798.         move.l    156(a3),d0        ; pr_CIS
  1799.         beq.s    6$
  1800.         bsr.s    getstdio2
  1801. 6$        RECALL    Permit
  1802.         tst.w    d4
  1803.         ble.s    7$
  1804. 1$        dbra    d3,3$
  1805. 7$        clr.l    (a0)+
  1806.         move.l    (sp)+,a5
  1807. 4$        rts
  1808.  
  1809. getstdio2    lsl.l    #2,d0            ; make APTR
  1810.         move.l    d0,a2
  1811.         and.b    #-4,d0
  1812.         cmp.l    a2,d0            ; LW aligned?
  1813.         bne.s    1$
  1814.         move.l    8(a2),d0        ; fh_Type
  1815.         ble.s    1$            ; negative = plain file
  1816.         move.l    d0,a2
  1817.         move.l    16(a2),d0        ; mp_SigTask
  1818.         beq.s    1$
  1819.         move.l    d0,(a0)+
  1820.         move.w    d2,(a1)+
  1821.         subq.w    #1,d4
  1822. 1$        rts
  1823.  
  1824. getaskdat    move.l    d5,-(sp)
  1825.         bsr.s    getaskdat2
  1826.         move.b    d5,entries(a4)
  1827.         move.l    (sp)+,d5
  1828.         beq.s    1$
  1829.         clr.w    tasksnum(a4)
  1830. 1$        moveq    #16,d2
  1831.         lea    -32(a5),a2
  1832.         bsr.s    sortlist
  1833.         rts
  1834.  
  1835. sortlist    tst.b    sorton(a4)
  1836.         beq.s    sort5
  1837.         lea    buffer(a4),a1
  1838. sort1        lea    0(a1,d2.w),a3
  1839. sort2        move.l    0(a1),d1
  1840.         cmp.l    0(a3),d1
  1841.         bge.s    sort3
  1842.         move.l    d2,d1
  1843.         subq.w    #1,d1
  1844. sort4        move.b    0(a3,d1.w),d0
  1845.         move.b    0(a1,d1.w),0(a3,d1.w)
  1846.         move.b    d0,0(a1,d1.w)
  1847.         dbra    d1,sort4
  1848. sort3        lea    0(a3,d2.w),a3
  1849.         cmp.l    a2,a3
  1850.         ble.s    sort2
  1851.         lea    0(a1,d2.w),a1
  1852.         cmp.l    a2,a1
  1853.         bne.s    sort1
  1854. sort5        rts
  1855.  
  1856. getaskdat2    move.l    sysbase(a4),a6
  1857.         lea    buffer(a4),a5
  1858. getaskdat3    moveq    #0,d5
  1859.         move.w    #$4000,$dff09a
  1860.         lea    stplist(a4),a3
  1861.         bsr.s    putlist
  1862.         lea    420(a6),a3        ; SysBase->TaskWait
  1863.         bsr.s    putlist
  1864.         lea    406(a6),a3        ; SysBase->TaskReady
  1865.         bsr.s    putlist
  1866.         move.l    276(a6),a3        ; SysBase->ThisTask
  1867.         bsr.s    putdata
  1868. 1$        move.w  #$C000,$dff09a
  1869.         rts
  1870.  
  1871. putlist        move.l    0(a3),a3
  1872.         tst.l    0(a3)
  1873.         beq.s    endlist
  1874.         bsr.s    putdata
  1875.         bra.s    putlist
  1876. endlist     rts
  1877.  
  1878. putdata     move.l    a3,(a5)+        ;  +0 = task node
  1879.         move.l    10(a3),(a5)+        ;  +4 = task->ln_Name
  1880.         move.b    8(a3),(a5)+        ;  +8 = task->ln_Type
  1881.         move.b    15(a3),(a5)+        ;  +9 = task->tc_State
  1882.         move.b    9(a3),(a5)+        ; +10 = task->ln_Pri
  1883.         move.b    143(a3),(a5)+        ; +11 = Process->pr_Tasknum
  1884.         move.w    tasksnum(a4),d0
  1885.         lea    cputime(a4),a0
  1886.         bra.s    pua2
  1887. pua3        move.l    500(a0),d1
  1888.         cmp.l    (a0)+,a3
  1889.         beq.s    pua1
  1890. pua2        dbra    d0,pua3
  1891.         moveq    #0,d1
  1892. pua1        move.l    d1,(a5)+        ; +12 = task time
  1893.         addq.w    #1,d5
  1894.         rts
  1895.  
  1896. alloctaskbuf    moveq    #(2816>>5),d0
  1897.         lsl.w    #5,d0
  1898.         moveq    #0,d1
  1899.         CALL    AllocMem,sysbase(a4)
  1900.         move.l    d0,-(sp)
  1901.         beq.s    1$
  1902.         move.l    d0,a5
  1903.         bsr    getaskdat3
  1904. 1$        move.l    (sp)+,d0
  1905.         rts
  1906.  
  1907. freetaskbuf    move.l    a5,a1
  1908.         moveq    #(2816>>5),d0
  1909.         lsl.w    #5,d0
  1910.         move.l    sysbase(a4),a6
  1911.         jmp    _LVOFreeMem(a6)
  1912.  
  1913. cleanuptimers    bsr.s    alloctaskbuf
  1914.         beq.s    2$
  1915.         moveq    #0,d1
  1916.         lea    taskstampid(a4),a1
  1917. 1$        lea    -16(a5),a5
  1918.         move.l    0(a5),d0
  1919.         bsr.s    gettimeentry
  1920.         lea    taskstampid(a4),a3
  1921.         lea    0(a3,d0.w),a3
  1922.         move.l    0(a3),d2
  1923.         move.l    0(a1),0(a3)
  1924.         move.l    d2,(a1)
  1925.         move.l    taskstamps-taskstampid(a3),d2
  1926.         move.l    taskstamps-taskstampid(a1),taskstamps-taskstampid(a3)
  1927.         move.l    d2,taskstamps-taskstampid(a1)
  1928.         move.l    usedtime-taskstampid(a3),d2
  1929.         move.l    usedtime-taskstampid(a1),usedtime-taskstampid(a3)
  1930.         move.l    d2,usedtime-taskstampid(a1)
  1931.         addq.l    #4,a1
  1932.         addq.w    #1,d1
  1933.         subq.b    #1,d5
  1934.         bne.s    1$
  1935.         move.w    d1,numtaskstimed(a4)
  1936.         bsr.s    freetaskbuf
  1937. 2$        rts
  1938.  
  1939. gettimeentry    movem.l    d1/a0/a1,-(sp)
  1940.         lea    taskstampid(a4),a1
  1941.         lea    4(a1),a0
  1942.         move.w    numtaskstimed(a4),d1
  1943.         subq.w     #1,d1
  1944. 1$        cmp.l    (a1)+,d0
  1945.         dbeq    d1,1$
  1946.         sub.l    a0,a1
  1947.         move.l    a1,d0
  1948.         movem.l    (sp)+,d1/a0/a1
  1949.         rts
  1950.  
  1951. getaskname2    movem.l    a3/a5,-(sp)
  1952.         link    a2,#-10
  1953.         move.l    sp,a5
  1954.         move.l    d0,a3
  1955.         tst.l    d0
  1956.         bne.s    2$
  1957.         bsr    putstr
  1958.         bra.s    1$
  1959. 2$        move.b    8(a3),8(a5)
  1960.         move.l    10(a3),4(a5)
  1961.         bsr.s    gettaskname
  1962. 1$        unlk    a2
  1963.         movem.l    (sp)+,a3/a5
  1964.         rts
  1965.  
  1966. gettaskname    movem.l    a1-a2,-(sp)
  1967.         clr.b    cliexec(a4)
  1968.         tst.b    cmdcli(a4)
  1969.         beq.s    2$
  1970.         cmpi.b    #13,8(a5)
  1971.         bne.s    2$
  1972.  
  1973.         CALL    Forbid,sysbase(a4)
  1974.         tst.l    140(a3)            ; pr_TaskNum
  1975.         beq.s    1$
  1976.         move.l    172(a3),d0        ; pr_CLI
  1977.         beq.s    1$
  1978.         lsl.l    #2,d0
  1979.         move.l    d0,a2
  1980.         tst.l    60(a2)            ; cli_Module
  1981.         beq.s    1$
  1982.         move.l    16(a2),a1
  1983.         adda.l    a1,a1
  1984.         adda.l    a1,a1
  1985.         tst.b    0(a1)
  1986.         beq.s    1$
  1987.         move.w    #openbrak,d0
  1988.         bsr    putstrw
  1989.         move.l    16(a2),d0        ; cli_CommandName
  1990.         bsr    putbcpl
  1991.         RECALL    Permit
  1992.         st    cliexec(a4)
  1993.         move.w    #closebrak,d0
  1994.         movem.l    (sp)+,a1-a2
  1995.         bra    putstrw
  1996.  
  1997. 1$        RECALL    Permit            ; a6 - still SysBase
  1998. 2$        move.l    4(a5),d0
  1999.         movem.l    (sp)+,a1-a2
  2000.         bra    putstr
  2001.  
  2002. gettype        moveq    #$f,d1
  2003.         and.l    d1,d0
  2004.         mulu    #11,d0
  2005.         add.w    #type,d0
  2006.         bra    putstrw
  2007.  
  2008. *-------- mem-hunks ------------
  2009.  
  2010. showmem        lea    mheader(a4),a0
  2011.         bsr    puthead
  2012.         move.l    sysbase(a4),a5
  2013.         lea    322(a5),a5        ; SysBase->MemList
  2014.         moveq    #0,d5
  2015. mem1        move.l    0(a5),a5        ; MemList->ln_Next
  2016.         tst.l    0(a5)
  2017.         beq.s    mem2
  2018.         move.l    20(a5),d0        ; MemHeader->mh_Lower
  2019.         bsr    hexa
  2020.         move.l    24(a5),d0        ; MemHeader->mh_Upper
  2021.         bsr    hexa
  2022.         move.l    28(a5),d0        ; MemHeader->mh_Free
  2023.         add.l    d0,d5
  2024.         moveq    #1,d3
  2025.         bsr    longdec
  2026.         move.w    14(a5),d0        ; MemHeader->mh_Attributes
  2027.         bsr    gthex
  2028.         addq.l    #3,d0
  2029.         move.l    d0,a0
  2030.         move.b    #'$',(a0)
  2031.         bsr    putstr
  2032.         move.b    9(a5),d3        ; MemHeader->ln_pri
  2033.         bsr    plusmins
  2034.         move.l    10(a5),d0        ; MemHeader->ln_Name
  2035.         move.l    a5,node(a4)
  2036.         bsr    putnam
  2037.         bra.s    mem1
  2038. mem2        move.w    #infoh6,d0
  2039.         bsr    putstrw
  2040.         moveq    #18,d1
  2041.         bsr    tab
  2042.         move.l    d5,d0
  2043.         moveq    #1,d3
  2044.         bsr    longdec
  2045.         bra    newline
  2046.  
  2047. frags        move.l    sysbase(a4),a5
  2048.         lea    322(a5),a5        ; SysBase->MemList
  2049. 1$        move.l    0(a5),a5        ; MemList->ln_Next
  2050.         tst.l    0(a5)
  2051.         bne.s    10$
  2052.         rts
  2053. 10$        move.w    #memtyp,d0
  2054.         bsr    putstrw
  2055.         move.l    10(a5),d0
  2056.         bsr    putnam
  2057.         lea    fraghead(a4),a0
  2058.         bsr    puthead
  2059.         lea    buffer(a4),a1
  2060.         move.l    a1,a2
  2061.         moveq    #64,d0
  2062. 9$        clr.l    (a2)+
  2063.         dbra    d0,9$
  2064.         lea    128(a1),a2
  2065.         lea    16(a5),a3        ; MemHeader->mh_First
  2066.  
  2067.         CALL    Forbid,sysbase(a4)
  2068. 2$        move.l    0(a3),d0
  2069.         beq.s    5$
  2070.         move.l    d0,a3
  2071.         move.l    4(a3),d0
  2072.         move.l    d0,d5
  2073.         moveq    #31,d1
  2074. 3$        add.l    d0,d0
  2075.         btst.l    #31,d0
  2076.         dbne    d1,3$
  2077.         lsl.l    #2,d1
  2078.         addq.l    #1,0(a1,d1.w)
  2079.         cmp.l    0(a2,d1.w),d5
  2080.         ble.s    2$
  2081.         move.l    d5,0(a2,d1.w)
  2082.         bra.s    2$
  2083. 5$        CALL    Permit,sysbase(a4)
  2084.  
  2085.         moveq    #0,d1
  2086. 8$        move.l    (a2)+,d5
  2087.         move.l    (a1)+,d2
  2088.         beq.s    6$
  2089.         moveq    #0,d0
  2090.         bset.l    d1,d0
  2091.         lsr.l    #1,d0
  2092.         move.l    d0,d4
  2093.         bsr    hexa
  2094.         move.l    d4,d0
  2095.         moveq    #1,d3
  2096.         bsr    longdec
  2097.         move.l    d2,d0
  2098.         bsr    longdec
  2099.         move.l    d5,d0
  2100.         bsr    longdec
  2101. 7$        bsr    newline
  2102. 6$        addq.w    #1,d1
  2103.         cmp.w    #31,d1
  2104.         ble.s    8$
  2105.         bsr    newline
  2106.         bra    1$
  2107.  
  2108. *-------- Task-Stack ------------
  2109.  
  2110. stack        lea    stackhead(a4),a0
  2111.         bsr    puthead
  2112.         moveq    #0,d5
  2113.         bsr    getaskdat
  2114.         bra    sta4
  2115. sta1        lea    -16(a5),a5
  2116.         bsr    hideit
  2117.         beq.s    sta4
  2118.         move.l    0(a5),a1
  2119.         cmp.l    idletask(a4),a1
  2120.         beq.s    sta4
  2121.         move.l    a1,node(a4)
  2122.         moveq    #1,d3            ; longdec right justified
  2123.         cmp.b    #13,8(a1)        ; task->ln_Type
  2124.         bne.s    sta2
  2125.         move.l    172(a1),d0        ; pr_CLI
  2126.         beq.s    sta2
  2127.         lsl.l    #2,d0
  2128.         move.l    d0,a0
  2129.         tst.l    60(a0)            ; cli_Module
  2130.         beq.s    sta2
  2131.         move.l    176(a1),a0
  2132.         move.l    (a0)+,d4        ; stacksize for this CLI-process
  2133.         move.l    a0,d0
  2134.         sub.l    d4,d0            ; (pr_ReturnAddress+4)-stacksize
  2135.         bsr    hexa
  2136.         move.l    d4,d0            ; stacksize
  2137.         bsr    longdec
  2138.         move.l    176(a1),d0        ; pr_ReturnAddress
  2139.         addq.l    #4,d0
  2140.         bra.s    sta3
  2141.  
  2142. sta2        move.l    58(a1),d0        ; tc_SPLower
  2143.         bsr    hexa
  2144.         move.l    62(a1),d4        ; tc_SPUpper
  2145.         sub.l    58(a1),d4        ; tc_SPLower
  2146.         move.l    d4,d0
  2147.         bsr    longdec
  2148.         move.l    62(a1),d0        ; tc_SPUpper
  2149. sta3        sub.l    54(a1),d0        ; tc_SPReg
  2150.         bcs.s    2$
  2151.         cmp.l    d4,d0
  2152.         ble.s    1$
  2153. 2$        moveq    #-1,d0            ; tc_SPReg outside ...
  2154. 1$        bsr    longdec
  2155.         move.l    a1,a3
  2156.         bsr    gettaskname
  2157.         bsr    newline
  2158. sta4        subq.b    #1,entries(a4)
  2159.         bcc    sta1            ; more entries
  2160.         rts
  2161.  
  2162. clicomm        lea    clicomhead(a4),a0
  2163.         bsr    puthead
  2164.         moveq    #0,d5
  2165.         bsr    getaskdat
  2166.         bra    clic0
  2167. clic1        lea    -16(a5),a5
  2168.         bsr    hideit
  2169.         beq    clic0
  2170.         move.l    0(a5),a2
  2171.         cmpi.b    #13,8(a2)        ; ln_Type
  2172.         bne    clic0
  2173.         tst.l    172(a2)
  2174.         beq    clic0
  2175.         move.l    140(a2),d3        ; pr_TaskNum
  2176.         beq     clic0
  2177.         move.l    a2,d0
  2178.         move.l    d0,node(a4)
  2179.         bsr    hexa
  2180.         moveq     #0,d0
  2181.         move.b    9(a5),d0
  2182.         subq.w    #1,d0
  2183.         mulu    #9,d0
  2184.         add.w    #status,d0
  2185.         bsr    putstrw
  2186.         move.l    172(a2),a3        ; pr_CLI
  2187.         adda.l    a3,a3
  2188.         adda.l    a3,a3
  2189.         move.w    #script,d0
  2190.         tst.l    40(a3)            ; cli_InterActive
  2191.         beq.s    clic5
  2192.         addq.w    #interact-script,d0
  2193. clic5        bsr    putstrw
  2194.         move.w    #backg,d0
  2195.         tst.l    44(a3)            ; cli_Background
  2196.         bne.s    clic6
  2197.         addq.w    #foreg-backg,d0
  2198. clic6        bsr    putstrw
  2199.         bsr    bytedec
  2200.         move.l    4(a5),d0
  2201.         bsr    putstr
  2202.         moveq    #49,d1
  2203.         bsr    tab
  2204.         bsr    putblank
  2205.         move.l    128(a2),d0        ; pr_SegList
  2206.         beq.s    noprogloadc
  2207. clic3        move.l    172(a2),d1        ; pr_CLI
  2208.         bne.s    clic4
  2209. noprogloadc    move.w    #longnix,d0
  2210.         bsr     putnamw
  2211.         bra.s    clic0
  2212. clic4        lsl.l    #2,d1
  2213.         move.l    d1,a2
  2214.         move.l    60(a2),d1        ; cli_Module
  2215.         beq.s    noprogloadc
  2216.         move.l    16(a2),d0        ; cli_CommandName
  2217.         bsr    putbcpl
  2218.         move.l    36(a2),d1        ; cli_CommandFile
  2219.         beq.s    1$
  2220.         move.l    d1,d2
  2221.         lsl.l    #2,d1
  2222.         move.l    d1,a0
  2223.         tst.b    0(a0)
  2224.         beq.s    1$
  2225.         bsr     putblank
  2226.         move.w    #openbrak,d0
  2227.         bsr    putstrw
  2228.         move.l    d2,d0
  2229.         bsr    putbcpl
  2230.         move.w    #closebrak,d0
  2231.         bsr    putstrw
  2232. 1$        bsr    newline
  2233.  
  2234. clic0        subq.b    #1,entries(a4)
  2235.         bcc    clic1
  2236. clic8        rts
  2237.  
  2238. *--------- interrupts ------------
  2239.  
  2240. showint        lea    iheader(a4),a0
  2241.         bsr    puthead
  2242.         lea    intnames(a4),a5
  2243.         lea    inttyp(a4),a1
  2244.         moveq    #0,d6
  2245. findint        moveq    #0,d1
  2246.         lea    inttyp(a4),a1
  2247.         moveq    #15,d5
  2248.         move.l    sysbase(a4),a3
  2249.         lea    84(a3),a3        ; SysBase->IntVects[16]
  2250. si0        tst.b    0(a1,d1.w)
  2251.         bne.s    si4
  2252.         move.l    8(a3),a2        ; IntVector->iv_Node
  2253.         bra.s    si5
  2254. si4        move.l    0(a3),a2        ; Interrupt->is_Node
  2255. si5        move.l    a2,d0
  2256.         beq    nxtint
  2257.         tst.b    0(a1,d1.w)
  2258.         beq.s    si1
  2259. si2        move.l    0(a2),a2        ; is_Node->ln_Next
  2260.         tst.l    0(a2)
  2261.         beq    nxtint
  2262. si1        tst.w    d6
  2263.         beq.s    3$
  2264.         cmp.l    a2,d4
  2265.         bne.s    4$
  2266.         rts
  2267. 3$        move.l    a2,node(a4)
  2268.         move.l    a2,d0
  2269.         bsr    hexa
  2270.         move.l    14(a2),d0        ; Interrupt->is_Data
  2271.         bsr    hexan
  2272.         move.l    18(a2),d0        ; Interrupt->is_Code
  2273.         bsr    hexan
  2274.         move.b    9(a2),d3        ; Interrupt->ln_Pri
  2275.         movem.l    d6/a3,-(sp)
  2276.         bsr    plusmins
  2277.         move.w    #intserv,d0
  2278.         tst.b    0(a1,d1.w)
  2279.         bne.s    1$
  2280.         move.w    #inthand,d0
  2281. 1$        bsr    putstrw
  2282.         move.w    #intdis,d0
  2283.         move.w    $dff01c,d3
  2284.         btst    d1,d3
  2285.         beq.s    2$
  2286.         move.w    #inten,d0
  2287. 2$        bsr    putstrw
  2288.         movem.l    (sp)+,d6/a3
  2289.         move.l    a5,d0
  2290.         bsr    putstr
  2291.         move.l    10(a2),d0        ; Interrupt->ln_Name
  2292.         bsr    putnam
  2293.         tst.b    0(a1,d1.w)
  2294.         bne    si2
  2295. 4$        tst.l    0(a2)
  2296.         beq.s    nxtint
  2297.         move.l    0(a2),a2
  2298.         bra    si1
  2299. nxtint        addq.w    #1,d1
  2300.         lea    12(a5),a5
  2301.         lea    12(a3),a3
  2302.         dbra    d5,si0
  2303.         rts
  2304.  
  2305. *---------    resident ------------
  2306.  
  2307. showresi    lea    rheader(a4),a0
  2308.         bsr    puthead
  2309.         move.l    sysbase(a4),a5
  2310.         move.l    300(a5),a5        ; SysBase->ResModules
  2311. r1        move.l    (a5)+,d0        ; Resident->ln_Next
  2312.         beq.s    r2
  2313.         bpl.s    r3
  2314.         bclr    #31,d0
  2315.         movea.l    d0,a5
  2316.         bra.s    r1
  2317. r3        move.l    d0,node(a4)
  2318.         movea.l    d0,a3
  2319.         bsr    hexa
  2320.         move.b    13(a3),d3        ; rt_Pri
  2321.         bsr    plusmins
  2322.         move.b    10(a3),d0        ; rt_Flags
  2323.         bsr    bin
  2324.         move.b    11(a3),d3        ; rt_Version
  2325.         bsr    bytedec
  2326.         move.b    12(a3),d0        ; rt_Type
  2327.         bsr    gettype
  2328.         move.l    14(a3),d0        ; rt_Name
  2329.         bsr    putnam
  2330.         bra.s    r1
  2331. r2        rts
  2332.  
  2333. *---------  ports  -------------
  2334.  
  2335. showprt        lea    pheader(a4),a0
  2336.         bsr    puthead
  2337.         moveq    #0,d5
  2338.         lea    buffer(a4),a5
  2339.         move.l    a5,-(sp)
  2340.         CALL    Forbid,sysbase(a4)
  2341.         move.w    #$4000,$dff09a
  2342.         bsr.s    getprts
  2343.         move.w    #$C000,$dff09a
  2344.         RECALL    Permit
  2345.         move.l    (sp)+,a5        ; buffer
  2346.         bra.s    sp2
  2347. sp1        move.l    (a5)+,d0
  2348.         move.l    d0,node(a4)
  2349.         bsr    hexa
  2350.         move.l    (a5)+,d0
  2351.         bsr    putstr
  2352.         moveq    #25,d1
  2353.         bsr     tab
  2354.         bsr    putblank
  2355.         moveq    #3,d0
  2356.         and.b    (a5)+,d0
  2357.         mulu    #9,d0
  2358.         add.w    #mp_flags,d0
  2359.         bsr    putstrw
  2360.         lea    bytedec(pc),a0
  2361.         move.b    (a5)+,d3
  2362.         jsr    0(a0)            ; bytedec
  2363.         move.w    (a5)+,d3
  2364.         bpl.s    1$
  2365.         lea    putstrw(pc),a0
  2366.         move.w    #toomuch,d0
  2367. 1$        jsr    0(a0)            ; bytedec or putstrw
  2368.         move.l    (a5)+,d0
  2369.         bsr    getaskname2
  2370.         bsr    newline
  2371. sp2        subq.w    #1,d5
  2372.         bcc.s    sp1
  2373.         rts
  2374.  
  2375. getprts        lea    392(a6),a3        ; SysBase->PortList
  2376. sp3        move.l    0(a3),a3        ; mp_Node.ln_Next
  2377.         tst.l    0(a3)
  2378.         beq.s    sp4
  2379.         bsr.s    getpdata
  2380.         bra.s    sp3
  2381. sp4        tst.b    tports(a4)
  2382.         beq.s    sp6
  2383.         move.l    276(a6),a3        ; SysBase->ThisTask
  2384.         lea     92(a3),a3        ; Process->pr_MsgPort
  2385.         bsr.s    getpdata
  2386.         lea    406(a6),a2        ; SysBase->TaskReady
  2387.         bsr.s    sp5
  2388.         lea    420(a6),a2        ; SysBase->TaskWait
  2389. sp5        move.l    0(a2),a2
  2390.         tst.l    0(a2)
  2391.         beq.s    sp6
  2392.         lea     92(a2),a3        ; pr_MsgPort
  2393.         cmp.b    #13,8(a2)        ; ln_Type
  2394.         bne.s    sp5
  2395.         bsr.s    getpdata
  2396.         bra.s    sp5
  2397. sp6        rts
  2398.  
  2399. getpdata    move.l    a3,(a5)+
  2400.         move.l    10(a3),(a5)+        ;  +4 = ln_Name
  2401.         move.b    14(a3),(a5)+        ;  +8 = mp_Flags
  2402.         move.b    15(a3),(a5)+        ;  +9 = mp_SigBit
  2403.         moveq    #0,d0
  2404.         suba.l    a0,a0
  2405.         movea.l    20(a3),a1        ; mp_MsgList
  2406. sp7        movea.l    0(a1),a1
  2407.         cmpa.l    a0,a1
  2408.         beq.s    sp8
  2409.         addq.b    #1,d0
  2410.         bcc.s    sp7            ; <256
  2411.         subq.w    #1,d0
  2412. sp8        move.w    d0,(a5)+        ; +10 = msgcnt
  2413.         move.l    16(a3),(a5)+        ; +12 = mp_SigTask
  2414.         addq.w    #1,d5
  2415.         rts
  2416.  
  2417. *-------- resources ------------
  2418.  
  2419. showres        lea    resnam(a4),a3
  2420.         move.w    #336,d3            ; SysBase->ResourceList
  2421.         bra.s    show
  2422.  
  2423. *--------- devices  -------------
  2424.  
  2425. showdevs    lea    devnam(a4),a3
  2426.         move.w    #350,d3            ; SysBase->DeviceList
  2427.         bra.s    show
  2428.  
  2429. *-------- libraries -------------
  2430.  
  2431. showlibs    lea    libnam(a4),a3
  2432.         move.w    #378,d3            ; SysBase->LibList
  2433.  
  2434. show        lea    lheader(a4),a0
  2435.         bsr    puthead1
  2436.         move.l    a3,a0
  2437.         bsr    puthead2
  2438.         moveq    #0,d5
  2439.         lea    buffer(a4),a5
  2440.         move.l    a5,-(sp)
  2441.         CALL    Forbid,sysbase(a4)
  2442.         lea    0(a6,d3.w),a3
  2443. sl1        move.l    0(a3),a3        ; lib_Node.ln_Next
  2444.         tst.l    0(a3)
  2445.         beq.s    sl2
  2446.         move.l    a3,(a5)+
  2447.         move.w    32(a3),(a5)+        ;  +4 = lib_OpenCnt
  2448.         move.w    20(a3),(a5)+        ;  +6 = lib_Version
  2449.         move.w    22(a3),(a5)+        ;  +8 = lib_Revision
  2450.         clr.b    (a5)+
  2451.         move.b    14(a3),(a5)+        ; +11 = lib_Flags
  2452.         move.l    10(a3),(a5)+        ; +12 = ln_Name
  2453.         addq.w    #1,d5
  2454.         bra.s    sl1
  2455. sl2        RECALL    Permit
  2456.         move.l    (sp)+,a5        ; buffer
  2457.         bra.s    sl4
  2458. sl3        move.l    (a5)+,d0
  2459.         move.l    d0,node(a4)
  2460.         bsr    hexa
  2461.         move.w    (a5)+,d3
  2462.         bsr    worddec
  2463.         move.w    (a5)+,d3
  2464.         bsr    worddec
  2465.         move.w    (a5)+,d3
  2466.         bsr    worddec
  2467.         move.w    (a5)+,d0
  2468.         bsr    bin
  2469.         move.l    (a5)+,d0
  2470.         bsr    putnam
  2471. sl4        subq.w    #1,d5
  2472.         bcc.s    sl3            ; not ready
  2473.         rts
  2474.  
  2475. ;--------- Semaphores ---------
  2476.  
  2477. semaphores    lea    semhead(a4),a0
  2478.         bsr    puthead
  2479.         move.l    sysbase(a4),a3
  2480.         lea    532(a3),a3
  2481.         bsr.s    sema
  2482.         tst.b    post_V34(a4)
  2483.         bne.s    sema6
  2484.         move.l    intuibase(a4),a3
  2485.         lea    1010(a3),a3
  2486. sema        moveq    #0,d5            ; examine list
  2487.         lea    buffer(a4),a5
  2488.         move.l    a5,-(sp)
  2489.         move.w    #$4000,$dff09a
  2490. sema2        move.l    0(a3),a3
  2491.         tst.l    0(a3)
  2492.         beq.s    sema3
  2493.         move.l    a3,(a5)+
  2494.         move.l    $28(a3),(a5)+
  2495.         move.b    $2d(a3),(a5)+
  2496.         move.b    $f(a3),(a5)+
  2497.         move.l    10(a3),(a5)+
  2498.         addq.w    #1,d5
  2499.         bra.s     sema2
  2500. sema3        move.w    #$C000,$dff09a
  2501.         move.l    (sp)+,a5        ; buffer
  2502.         bra.s    sema5
  2503. sema4        move.l    (a5)+,d0
  2504.         bsr    hexa
  2505.         move.l    (a5)+,d0
  2506.         bsr    getaskname2
  2507.         moveq    #24,d1
  2508.         bsr    tab
  2509.         moveq    #1,d3
  2510.         add.b    (a5)+,d3
  2511.         bsr    plusmins
  2512.         move.b    (a5)+,d3
  2513.         bsr    plusmins
  2514.         move.l    (a5)+,d0
  2515.         bsr    putnam
  2516. sema5        subq.w    #1,d5
  2517.         bcc.s    sema4            ; not ready
  2518. sema6        rts
  2519.  
  2520. ; unlock a file
  2521.  
  2522. unlock        tst.b    fromfile(a4)
  2523.         bne.s    ul6
  2524.         bsr    readhex
  2525.         tst.b    d7
  2526.         beq    syntax
  2527.         move.l    d0,remembr(a4)
  2528.         move.l    d0,-(sp)
  2529.         moveq    #-1,d6
  2530.         bsr.s    of44
  2531.         tst.l    remembr(a4)
  2532.         beq.s     ul1
  2533.         move.w    #unlerr,d0
  2534.         bsr    putnamw
  2535.         bra.s    ul4
  2536. ul1        bsr    allocfinfo
  2537.         bsr    ResumeOutput
  2538.         move.w    #unl1,d0
  2539.         bsr    putstrw
  2540.         move.l    0(sp),d0
  2541.         bsr    getpath
  2542.         move.w    #unltxt2,d0
  2543.         bsr    putstrw
  2544.         bsr    readline
  2545.         cmp.b    #'y',d0
  2546.         bne.s     ul5
  2547.         move.l    0(sp),d1
  2548.         CALL    UnLock,dosbase(a4)
  2549. ul5        bsr    freefinfo
  2550. ul4        addq.l    #4,sp
  2551. ul6        rts
  2552.  
  2553. ;---------- Show all Locks------------
  2554.  
  2555. locks        moveq    #0,d6
  2556.         bra.s    of33
  2557.  
  2558. ;---------- Open Files-----------
  2559.  
  2560. openfiles    moveq    #1,d6
  2561. of33        lea    ofheader(a4),a0
  2562.         bsr    puthead
  2563. of44        bsr    allocfinfo
  2564.         bsr    devinfo            ; get pointer to devicelist
  2565.         move.l    a1,a3
  2566. of1        move.l    a3,devicelock(a4)
  2567.         adda.l    a3,a3
  2568.         adda.l    a3,a3
  2569.         moveq    #2,d2             ; 2 = DLT_VOLUME
  2570.         cmp.l    4(a3),d2        ; dol_Type 
  2571.         bne    of2
  2572.         lea    buffer(a4),a5
  2573.         move.l    a5,a1
  2574.         move.l    40(a3),a2        ; dol_Name ('\0' terminated!)
  2575.         adda.l    a2,a2
  2576.         adda.l    a2,a2
  2577.         addq.w    #1,a2
  2578. of22        move.b    (a2)+,(a1)+
  2579.         bne.s    of22
  2580.         subq.w    #1,a1
  2581.         move.b  #':',(a1)+
  2582.         clr.b    0(a1)
  2583.         tst.b    post_V34(a4)
  2584.         bne.s    of5
  2585.         cmp.l    #'RAM ',0(a5)        ; hack to access the 'RAM Disk'
  2586.         bne.s    of5
  2587.         cmp.l    #'Disk',4(a5)        ; as 'RAM:' as the system may
  2588.         bne.s    of5
  2589.         move.l    #'M:'<<16,2(a5)        ; GURU with KS 1.2
  2590. of5        move.l    a5,d1
  2591.         moveq    #-2,d2
  2592.         CALL    Lock,dosbase(a4)    ; get a lock to the device
  2593.         move.l    d0,d2            ; not mounted' if fails
  2594.         bne.s    of6
  2595.         move.l    a5,d0            ; buffer points to device name
  2596.         bsr    putstr
  2597.         move.w    #nomount,d0
  2598.         bsr    putnamw
  2599.         bra    of2
  2600.  
  2601. of6        CALL    Forbid,sysbase(a4)
  2602.         move.l    d2,-(sp)        ; d2 = FileLock
  2603.         lea    buffer+40(a4),a6    ; where to store the locks we find
  2604.         move.l    d2,d0
  2605. of4        lsl.l    #2,d0
  2606.         move.l    d0,a5
  2607.         moveq    #50,d1
  2608.         move.l    0(a5),d0        ; fl_Link
  2609.         cmp.l    d1,d0            ; zero or bogus ?
  2610.         ble.s    1$            ; exit loop
  2611.         movem.l    d0/d1/a0/a1/a6,-(sp)
  2612.         lsl.l    #2,d0
  2613.         move.l    d0,a1
  2614.         CALL    TypeOfMem,sysbase(a4)
  2615.         tst.l    d0            ; valid ?
  2616.         movem.l    (sp)+,d0/d1/a0/a1/a6
  2617.         beq.s    1$
  2618.         move.l    d0,(a6)+        ; put lock into buffer
  2619.         tst.l    d6            ; searching for a lock ?
  2620.         bpl.s    of4            ; no !
  2621.         cmp.l    remembr(a4),d0        ; yes, compare them
  2622.         bne.s    of4
  2623.         clr.l    remembr(a4)
  2624.         CALL    Permit,sysbase(a4)
  2625.         move.l    (sp)+,d1
  2626.         CALL    UnLock,dosbase(a4)
  2627.         bra    of55            ; exit if found
  2628.  
  2629. 1$        clr.l    (a6)+            ; end of buffer marker
  2630.         CALL    Permit,sysbase(a4)
  2631.         tst.l    d6            ; just searching for a lock ?
  2632.         bmi    of3             ; skip printing out info
  2633.  
  2634. of45        lea    buffer+40(a4),a2    ; a2-> array of locks
  2635. of46        move.l    (a2)+,d0        ; get a lock
  2636.         beq    of3             ; end of list ?
  2637.         move.l    d0,d5
  2638.         lsl.l    #2,d0            ; bptr -> aptr
  2639.         move.l    d0,a5
  2640.         move.l    8(a5),d4        ; fl_Access
  2641.         move.l    d5,d0
  2642.         bsr    getfinfo        ; get fileinfo
  2643.         move.l    finfoptr(a4),a5
  2644.         tst.l    d6
  2645.         beq.s    of8
  2646.         bmi.s    of8             ; looking for open files ?
  2647.         tst.l    4(a5)            ; fib_DirEntryType
  2648.         bpl.s    of46            ; not a file
  2649. of8        move.l    d5,d0
  2650.         move.l    d0,node(a4)
  2651.         bsr    hexa            ; display lock
  2652.         move.w    #access,d0        ; access mode
  2653.         cmp.w    #-2,d4
  2654.         beq.s    of7
  2655.         addq.w  #8,d0
  2656. of7        bsr    putstrw
  2657.         tst.l    4(a5)            ; size
  2658.         bmi.s    of9
  2659.         move.w    #longlongnix,d0
  2660.         bsr    putstrw
  2661.         bra.s    of10
  2662. of9        move.l    124(a5),d0
  2663.         moveq    #1,d3
  2664.         bsr    longdec
  2665. of10        move.l    d5,d0            ; path and filename
  2666.         bsr    getpath
  2667.         bra.s    of46
  2668.  
  2669. of3        move.l    (sp)+,d1
  2670.         CALL    UnLock,dosbase(a4)
  2671. of2        move.l    0(a3),d0
  2672.         move.l    d0,a3
  2673.         bne    of1
  2674. of55        bsr    freefinfo
  2675.         rts
  2676.  
  2677. ;---------- Dos Devices ----------
  2678.  
  2679. devices        lea    ddheader(a4),a0
  2680.         bsr    puthead
  2681.         bsr    devinfo
  2682. dev1        adda.l    a1,a1
  2683.         adda.l    a1,a1
  2684.         tst.l    4(a1)
  2685.         bne    dev9
  2686.         moveq    #0,d6
  2687.         move.l    40(a1),d0
  2688.         bsr    putbcpl
  2689.         moveq    #10,d1
  2690.         bsr    tab
  2691.         move.w    #notfile,d0
  2692.         lea    putstrw(pc),a0
  2693.         moveq    #64,d1
  2694.         move.l    28(a1),a3
  2695.         cmp.l    d1,a3
  2696.         ble.s    dev3            ; <=64
  2697.         adda.l    a3,a3
  2698.         adda.l    a3,a3
  2699.         move.l    8(a3),a2
  2700.         cmp.l    d1,a2
  2701.         ble.s    dev3            ; <=64
  2702.         adda.l    a2,a2
  2703.         adda.l    a2,a2
  2704.         movem.l    d0/d1/a0/a1/a6,-(sp)
  2705.         move.l    a2,a1
  2706.         CALL    TypeOfMem,sysbase(a4)
  2707.         tst.l    d0            ; valid ?
  2708.         movem.l    (sp)+,d0/d1/a0/a1/a6
  2709.         beq.s    dev3
  2710.         moveq    #1,d6
  2711.         move.l    12(a2),d3
  2712.         bsr    bytedec
  2713.         move.l    20(a2),d0
  2714.         moveq    #1,d3
  2715.         lea    longdec(pc),a0
  2716.         jsr    0(a0)            ; longdec
  2717.         move.l    40(a2),d0
  2718.         beq.s    dev2
  2719.         addq.l    #1,d0
  2720.         sub.l    36(a2),d0
  2721. dev2        jsr    0(a0)            ; longdec
  2722.         move.l    44(a2),d0
  2723. dev3        jsr    0(a0)            ; putstrw or longdec
  2724. dev4        move.w    #devload,d0
  2725.         tst.l    8(a1)
  2726.         bne.s    dev5
  2727.         move.w    #devnload,d0
  2728. dev5        bsr    putstrw
  2729.         lea    putbcpl(pc),a0
  2730.         tst.w    d6
  2731.         beq.s    dev6
  2732.         move.l    4(a3),d0
  2733.         bne.s    dev7
  2734. dev6        move.l    16(a1),d0
  2735.         bne.s    dev7
  2736.         move.l    8(a1),d0
  2737.         beq.s    dev8
  2738.         move.l    d0,a3
  2739.         tst.b    14(a3)
  2740.         bne.s    dev8            ; mp_SigTask not a task!
  2741.         move.l    16(a3),d0
  2742.         beq.s    dev8            ; NULL!
  2743.         move.l    d0,a3
  2744.         lea    putstr(pc),a0
  2745.         move.l    10(a3),d0
  2746. dev7        jsr    0(a0)            ; putbcpl or putstr
  2747. dev8        bsr    newline
  2748. dev9        move.l    (a1),d1
  2749.         move.l    d1,a1
  2750.         bne    dev1
  2751.         rts
  2752.  
  2753. ; Re-assign a drive to dos
  2754.  
  2755. freedrive    moveq    #0,d2
  2756.         bra.s    ldr3
  2757.  
  2758. ; Inhibit a disk drive
  2759.  
  2760. lockdrive    moveq    #1,d2
  2761. ldr3        bsr    getstr
  2762.         bsr    finddev
  2763.         lea    buffer(a4),a2
  2764.         bne.s    ldr1
  2765. ldr2        move.l    a2,d0            ; buffer
  2766.         bsr    putstr
  2767.         move.w    #nomount,d0
  2768.         bsr    putstrw
  2769.         move.w    #dishelp,d0
  2770.         bra     putnamw
  2771. ldr1        move.l    a2,d1            ; buffer
  2772.         CALL    DeviceProc,dosbase(a4)
  2773.         move.l    d0,a0
  2774.         move.l    a0,d0
  2775.         beq.s    ldr2
  2776.         moveq    #31,d0
  2777.         move.l    d2,d1
  2778.  
  2779. ; send a packet
  2780. ; d0 = packet type
  2781. ; d1 = arg1
  2782. ; a0 = msgport
  2783.  
  2784. cons1        lea    mypacket(a4),a1
  2785.         lea    20(a1),a2
  2786.         move.l    a2,10(a1)        ; sp_Pkt to sp_Msg->ln_Name
  2787.         move.l    a1,20(a1)        ; sp_Msg to sp_Pkt->dp_Link
  2788.         move.l    replyport(a4),a2
  2789.         move.l    a2,24(a1)        ; sp_Pkt->dp_Port
  2790.         move.l    d0,28(a1)        ; sp_Pkt->dp_Type
  2791.         move.l    d1,40(a1)        ; sp_Pkt->dp_Arg1
  2792.         CALL    PutMsg,sysbase(a4)
  2793.         move.l    a2,a0
  2794.         RECALL    WaitPort
  2795.         move.l    a2,a0
  2796.         jmp    _LVOGetMsg(a6)
  2797.  
  2798. ;display the current directory of all processes,
  2799.  
  2800. currentdir    lea    cdheader(a4),a0
  2801.         bsr    puthead
  2802.         bsr    allocfinfo
  2803.         bsr    alloctaskbuf
  2804.         beq.s    cd7
  2805.         move.l    d0,a5
  2806.         move.b    d5,entries(a4)
  2807.         move.l    a5,-(sp)
  2808.         bra.s    cd6
  2809. cd2        cmp.b    #13,8(a5)
  2810.         bne.s    cd5
  2811.         move.l    0(a5),a3
  2812.         move.l    a5,-(sp)
  2813.         moveq    #-1,d6
  2814.         move.l    152(a3),remembr(a4)
  2815.         bsr    of44
  2816.         move.l    (sp)+,a5
  2817.         tst.l    remembr(a4)
  2818.         bne.s    cd5
  2819.         move.l    0(a5),a3
  2820.         move.l    a3,node(a4)
  2821.         bsr    gettaskname
  2822.         moveq    #21,d1
  2823.         bsr    tab
  2824.         move.l    152(a3),d0
  2825.         bsr    getpath
  2826. cd5        lea     16(a5),a5
  2827. cd6        subq.b    #1,entries(a4)
  2828.         bcc.s    cd2            ; not ready
  2829.         move.l    (sp)+,a5
  2830.         bsr    freetaskbuf
  2831.         bsr    freefinfo
  2832. cd7        rts
  2833.  
  2834. ;Change the current directory setting of a process
  2835.  
  2836. cd        tst.b    fromfile(a4)
  2837.         bne.s    cd7
  2838.         bsr    getstr
  2839.         lea    buffer(a4),a1
  2840.         move.l    a1,d1
  2841.         moveq    #-2,d2
  2842.         move.l    a0,-(sp)
  2843.         CALL    Lock,dosbase(a4)
  2844.         move.l    (sp)+,a0
  2845.         tst.l    d0
  2846.         bne.s    cd16
  2847.         move.w    #dnotf,d0
  2848.         bra    putnamw
  2849. cd16        move.l    d0,remembr2(a4)
  2850.         move.l    a0,-(sp)
  2851.         bsr    allocfinfo
  2852.         move.l    remembr2(a4),d0
  2853.         bsr    getfinfo
  2854.         move.l    finfoptr(a4),a5
  2855.         move.l    (sp)+,a0
  2856.         tst.l    4(a5)
  2857.         bpl.s    cd11
  2858.         move.w    #notdir,d0
  2859.         bsr    putnamw
  2860.         bra.s    cd18
  2861. cd11        bsr    nodenam
  2862.         moveq    #2,d7
  2863.         lea    TRuNode(pc),a3
  2864.         bsr    findnam
  2865.         tst.b    d7
  2866.         beq.s    cd15
  2867.         move.l    d0,a5
  2868.         cmp.b    #13,8(a5)
  2869.         beq.s    cd15
  2870.         bsr    syntax
  2871.         bra.s    cd18
  2872. cd15        move.l    152(a5),d0
  2873.         beq.s    cd13
  2874.         move.l    a5,-(sp)
  2875.         moveq    #-1,d6
  2876.         move.l    d0,remembr(a4)
  2877.         bsr    of44
  2878.         move.l    (sp)+,a5
  2879.         tst.l    remembr(a4)
  2880.         bne.s    cd18
  2881. cd13        move.l    152(a5),d1
  2882.         move.l    remembr2(a4),152(a5)
  2883.         move.l    d1,remembr2(a4)
  2884. cd12        beq.s     cd14
  2885.         bsr    ResumeOutput
  2886.         move.w    #unltxt,d0
  2887.         bsr    putstrw
  2888.         move.l    remembr2(a4),d0
  2889.         bsr    getpath
  2890.         move.w    #unltxt2,d0
  2891.         bsr    putstrw
  2892.         bsr    readline
  2893.         cmp.b     #'y',d0
  2894.         bne.s    cd14
  2895. cd18        move.l    remembr2(a4),d1
  2896.         beq.s    cd14
  2897.         CALL    UnLock,dosbase(a4)
  2898. cd14        bsr    freefinfo
  2899.         rts
  2900.  
  2901. ;find the first entry in the device-list
  2902. ;returns a1 = pointer to first entry
  2903.  
  2904. devinfo        move.l    dosbase(a4),a1
  2905.         move.l    34(a1),a1        ; dl_Root
  2906.         move.l    24(a1),a1        ; RootNode->rn_Info
  2907.         adda.l    a1,a1
  2908.         adda.l    a1,a1
  2909.         move.l    4(a1),a1        ; DosInfo->di_DevInfo
  2910.         rts
  2911.  
  2912. ; Check if a named dos-device is mounted
  2913. ; name in 'buffer'.
  2914. ; Result: d0 = 0(false) anything else(true).
  2915.  
  2916. finddev        bsr.s    devinfo
  2917. fdev1        adda.l    a1,a1
  2918.         adda.l    a1,a1
  2919.         tst.l    4(a1)
  2920.         bne.s    fdev2
  2921.         move.l    40(a1),a2
  2922.         lea    buffer(a4),a0
  2923.         bsr.s    strbcmp
  2924.         tst.w    d0
  2925.         bne.s    fdev3
  2926. fdev2        move.l    0(a1),d0
  2927.         move.l    d0,a1
  2928.         bne.s    fdev1
  2929. fdev3        rts
  2930.  
  2931. ; compare bcpl string with string
  2932. ; a0 = pointer to string
  2933. ; a2 = bcpl-pointer to bcpl-string
  2934. ; returns d0 = true(0) false(1)
  2935.  
  2936. strbcmp        movem.l    d1/a0/a2,-(sp)
  2937.         moveq    #0,d0
  2938.         moveq    #0,d1
  2939.         adda.l    a2,a2
  2940.         adda.l    a2,a2
  2941.         move.b    (a2)+,d1
  2942.         beq.s    stb1
  2943.         subq.w    #1,d1
  2944. stb2        cmp.b    (a2)+,(a0)+
  2945.         bne.s    stb1
  2946.         dbra    d1,stb2
  2947.         moveq    #1,d0
  2948. stb1        movem.l    (sp)+,d1/a0/a2
  2949.         rts
  2950.  
  2951. ;--------- low memory handlers --------
  2952.  
  2953. lowmemhandler    lea    inheader(a4),a0
  2954.         bsr    puthead
  2955.         tst.b    post_V38(a4)
  2956.         beq.s    inph1            ; not Kick 3.0+
  2957.         move.l    sysbase(a4),a5
  2958.         lea    616(a5),a5
  2959.         bra.s    inph2            ; show all handlers
  2960.  
  2961. ;----------- input handlers -----------
  2962.  
  2963. inputhandler    lea    inheader(a4),a0
  2964.         bsr    puthead
  2965.  
  2966.         lea    ininterrupt(a4),a5
  2967. 1$        move.l    0(a5),a5        ; get list header
  2968.         tst.l    0(a5)
  2969.         bne.s    1$
  2970.         subq.l    #4,a5            ; found it
  2971.  
  2972. inph2        move.l    0(a5),a5
  2973.         tst.l    0(a5)
  2974.         beq.s    inph1
  2975.         move.l    a5,d0
  2976.         move.l    d0,node(a4)
  2977.         bsr    hexa
  2978.         move.l    14(a5),d0
  2979.         bsr    hexa
  2980.         move.l    18(a5),d0
  2981.         bsr    hexa
  2982.         move.b    9(a5),d3
  2983.         bsr    plusmins
  2984.         move.l    10(a5),d0
  2985.         bsr    putnam
  2986.         bra.s    inph2
  2987. inph1        rts
  2988.  
  2989. ;display list of public screens
  2990.  
  2991. pubscreens    lea    pscrheader(a4),a0
  2992.         bsr    puthead
  2993.         tst.b    post_V34(a4)
  2994.         beq.s    1$            ; only Kick 2.0+
  2995.         CALL    LockPubScreenList,intuibase(a4)
  2996.         movea.l    d0,a5
  2997.         move.l    a5,d0
  2998.         beq.s    1$            ; no list ???
  2999. 5$        movea.l    0(a5),a5
  3000.         tst.l    0(a5)
  3001.         beq.s    2$            ; end of list
  3002.         move.l    a5,d0
  3003.         move.l    d0,node(a4)
  3004.         bsr    hexa            ; node
  3005.         move.l    10(a5),d0
  3006.         bsr    putstr            ; name
  3007.         moveq    #25,d1
  3008.         bsr    tab
  3009.         move.w    #pscr_state,d0
  3010.         btst    #0,19(a5)        ; public or private ?
  3011.         beq.s    4$
  3012.         add.w    #10,d0
  3013. 4$        bsr    putstrw            ; state
  3014.         lea    bytedec(pc),a0
  3015.         move.w    22(a5),d3        ; visit count (locks & windows)
  3016.         jsr    0(a0)
  3017.         move.b    28(a5),d3
  3018.         bpl.s    3$            ; valid signal
  3019.         move.w    #nix,d0
  3020.         lea    putstrw(pc),a0
  3021. 3$        jsr    0(a0)
  3022.         move.l    24(a5),d0        ; sigtask
  3023.         bsr    getaskname2
  3024.         bsr    newline
  3025.         bra.s    5$
  3026. 2$        CALL    UnlockPubScreenList,intuibase(a4)
  3027. 1$        rts
  3028.  
  3029. ;get all screen pointers.
  3030. ;result: d5=number of screens
  3031. ;     buffer+100 holds pointers.
  3032.  
  3033. getscr        lea    scrheader(a4),a0
  3034.         bsr    puthead
  3035. getscr2     movem.l    d0/a0,-(sp)
  3036.         moveq    #0,d0
  3037.         CALL    LockIBase,intuibase(a4)
  3038.         lea    buffer+100(a4),a0
  3039.         move.l    60(a6),a1        ; firstscreen
  3040.         moveq    #0,d5
  3041. sr1        addq.w    #1,d5
  3042.         move.l    a1,(a0)+
  3043.         move.l    0(a1),a1
  3044.         move.l    a1,d1
  3045.         bne.s    sr1
  3046.         subq.w    #1,d5
  3047.         move.l    d0,a0
  3048.         RECALL    UnlockIBase
  3049.         movem.l    (sp)+,d0/a0
  3050.         rts
  3051.  
  3052. ;display screen infos
  3053.  
  3054. screens        bsr.s    getscr
  3055.         moveq    #1,d6
  3056.         lea    buffer+100(a4),a5
  3057. sr2        move.w    d6,d3
  3058.         bsr    bytedec            ; number
  3059.         move.l    (a5)+,a2
  3060.         move.l    a2,node(a4)
  3061.         move.l    a2,d0
  3062.         bsr    hexa            ; address
  3063.         move.w    12(a2),d0
  3064.         moveq     #4,d3
  3065.         bsr    longdecn        ; width
  3066.         moveq    #'X',d0
  3067.         bsr    putchar
  3068.         move.w    14(a2),d0
  3069.         bsr    longdecn        ; height
  3070.         move.b    189(a2),d3
  3071.         bsr     bytedec
  3072.         move.l    22(a2),d0        ; depth
  3073.         bsr    putnam            ; name
  3074.         tst.b    post_V34(a4)
  3075.         beq.s    sr5            ; only kick 2.0+
  3076.         move.w    #monitorid,d0
  3077.         bsr    putstrw
  3078.         lea    44(a2),a0        ; ViewPort
  3079.         CALL    GetVPModeID,gfxbase(a4)
  3080.         move.l    d0,-(sp)
  3081.         bsr    hexa            ; DisplayID
  3082.         move.l    #'-> ',d0
  3083.         bsr    putlongascii
  3084.         move.l    (sp)+,d0
  3085.         RECALL    FindDisplayInfo
  3086.         move.l    d0,d2
  3087.         beq.s    sr3            ; no handle
  3088.         move.l    d0,a0
  3089.         lea    -104(a5),a1
  3090.         moveq    #56,d0            ; nif_SIZEOF
  3091.         move.l    #$80003000,d1        ; DTAG_NAME
  3092.         moveq    #0,d2
  3093.         RECALL    GetDisplayInfoData
  3094. sr3        lea    -88(a5),a0        ; NameInfo.Name
  3095.         cmp.l    d2,d0
  3096.         bne.s    sr4            ; ok !
  3097.         move.l    #'???'<<8,(a0)
  3098. sr4        move.l    a0,d0
  3099.         bsr    putnam            ; name + LF
  3100. sr5        addq.w    #1,d6            ; next screen
  3101.         dbra    d5,sr2
  3102.         rts
  3103.  
  3104. ;display windows and associated fonts
  3105. windowfonts    moveq    #1,d0
  3106.         bra.s    windows1
  3107.  
  3108. ;display window addresses and titles
  3109. windows        moveq    #0,d0
  3110. windows1    move.b    d0,bool(a4)
  3111.         bsr    getscr2
  3112.         move.l    d5,-(sp)
  3113.         lea    wnheader(a4),a0
  3114.         bsr    puthead
  3115.         move.l    (sp)+,d5
  3116.         tst.b    bool(a4)
  3117.         beq.s    wn20
  3118.         move.l    d5,-(sp)
  3119.         lea    fohead(a4),a0
  3120.         bsr    puthead
  3121.         move.l    (sp)+,d5
  3122. wn20        lea    buffer+100(a4),a3
  3123. wn2        move.w    #onscr,d0
  3124.         bsr    putstrw
  3125.         move.l    (a3)+,a2
  3126.         move.l    22(a2),d0
  3127.         bsr    putnam
  3128.         lea    4(a2),a1
  3129. wn1        move.l    (a1),d0
  3130.         move.l    d0,a1
  3131.         beq.s    wn3
  3132.         move.l    d0,node(a4)
  3133.         bsr    hexa
  3134.  
  3135.         move.l    86(a1),d0        ; wn->UserPort
  3136.         beq.s    1$
  3137.         move.l    d0,a0
  3138.         move.l    16(a0),d0        ; SigTask
  3139. 1$        bsr    getaskname2
  3140.         moveq    #20,d1
  3141.         bsr    tab
  3142.         bsr    putblank
  3143.  
  3144.         moveq    #4,d3
  3145.         moveq    #2,d2
  3146.         lea    4(a1),a0
  3147. 2$        move.w    (a0)+,d0
  3148.         bsr    longdecn
  3149.         dbra    d2,2$
  3150.         moveq    #'X',d0
  3151.         bsr    putchar
  3152.         move.w    10(a1),d0
  3153.         bsr    longdecn
  3154.  
  3155.         move.l    32(a1),d0
  3156.         bsr    putnam
  3157.  
  3158.         tst.b    bool(a4)
  3159.         beq.s    wn21
  3160.         move.l    a1,-(sp)
  3161.         move.l    50(a1),a1
  3162.         move.l    52(a1),a1
  3163.         bsr    fontdata
  3164.         move.l    (sp)+,a1
  3165.  
  3166. wn21        bra.s    wn1
  3167. wn3        dbra    d5,wn2
  3168.         rts
  3169.  
  3170. ;close a specified screen
  3171.  
  3172. closescreen    bsr    getscr2
  3173.         moveq    #1,d6
  3174.         cmp.b    #'$',0(a0)
  3175.         bne.s    cs1
  3176.         bsr    readhex
  3177.         tst.w    d7
  3178.         beq    syntax
  3179.         move.l    d0,d4
  3180. csin        moveq    #0,d6
  3181. cs1        lea    buffer+100(a4),a2
  3182. cs5        tst.w    d6
  3183.         bne.s    cs2
  3184.         cmp.l    (a2)+,d4
  3185.         beq.s    cs3
  3186.         bra.s    cs4
  3187. cs2        move.l    (a2)+,a1
  3188.         move.l    22(a1),a1
  3189.         bsr    strcmp
  3190.         beq.s    cs3
  3191. cs4        dbra    d5,cs5
  3192.         move.w    #scnofound,d0
  3193.         bra    putnamw
  3194. cs3        move.l    -(a2),a0
  3195.         cmp.l    screenptr(a4),a0    ; own screen ?
  3196.         beq.s    cs8
  3197.         move.l    4(a0),d0        ; Screen->FirstWindow
  3198.         beq.s    cs7
  3199.         move.l    a0,-(sp)
  3200. cs6        move.l    d0,a3
  3201.         move.l    (a3),-(sp)        ; Window->NextWindow
  3202.         bsr.s    clw
  3203.         move.l    (sp)+,d0
  3204.         bne.s    cs6            ; more windows !
  3205.         move.l    (sp)+,a0
  3206. cs7        CALL    CloseScreen,intuibase(a4)
  3207. cs8        rts
  3208.  
  3209. ;close a specified window
  3210.  
  3211. closewindow    bsr.s    getwnptr        ; get windowptr
  3212. clw        move.l    a3,d0            ; close win in a3
  3213.         beq.s    cs8
  3214.         cmp.l    wnptr(a4),a3        ; own window ?
  3215.         beq.s    cs8
  3216.         move.l    intuibase(a4),a6
  3217. cw1        move.l    36(a3),d0
  3218.         move.l    d0,a0
  3219.         beq.s    cw2
  3220.         move.w    #_LVOFreeSysRequest,d1
  3221.         move.w    28(a0),d0
  3222.         and.w    #$4000,d0
  3223.         bne.s    cw3
  3224.         move.l    a3,a1
  3225.         RECALL    EndRequest
  3226.         bra.s    cw1
  3227.  
  3228. cw2        move.w    #_LVOModifyIDCMP,d1    ; d0 already zero !
  3229.         bsr.s    cw3
  3230.         move.w    #_LVOCloseWindow,d1
  3231. cw3        move.l    a3,a0
  3232.         jmp    0(a6,d1.w)        ; CloseWin/FreeSysReq/ModIDCMP
  3233.  
  3234. getwnptr    bsr    getscr2
  3235.         moveq    #1,d6
  3236.         cmp.b    #'$',0(a0)
  3237.         bne.s    cw4
  3238.         bsr    readhex
  3239.         tst.w    d7
  3240.         bne.s    cwin
  3241.         bsr    syntax
  3242.         bra.s    cw10
  3243. cwin        move.l    d0,d4
  3244.         moveq    #0,d6
  3245. cw4        lea    buffer+100(a4),a2
  3246. cw5        move.l    (a2)+,a3
  3247.         move.l    4(a3),d0
  3248.         beq.s    cw9
  3249. cw6        move.l    d0,a3
  3250.         tst.w    d6
  3251.         bne.s    cw7
  3252.         cmp.l    a3,d4
  3253.         beq.s    cw11
  3254.         bra.s    cw8
  3255. cw7        move.l    32(a3),a1
  3256.         bsr    strcmp
  3257.         beq.s    cw11
  3258. cw8        move.l    0(a3),d0
  3259.         bne.s    cw6
  3260. cw9        dbra    d5,cw5
  3261.         move.w    #winnofound,d0
  3262.         bsr    putnamw
  3263. cw10        suba.l    a3,a3
  3264. cw11        rts
  3265.  
  3266. windowoff    movem.l    d1-d7/a0-a6,-(sp)
  3267.         bsr    getscr2
  3268.         bsr.s    cwin
  3269.         move.l    a3,d1
  3270.         beq.s    woff1
  3271.         bsr    clw
  3272.         move.l    -(a2),a0
  3273.         move.l    a0,d4
  3274.         tst.l    4(a0)
  3275.         bne.s    woff1
  3276.         bsr    getscr2
  3277.         bsr    csin
  3278. woff1        movem.l    (sp)+,d1-d7/a0-a6
  3279.         rts
  3280.  
  3281. closetskwin    movem.l    d1-d7/a0-a6,-(sp)
  3282. ctw0        bsr    getscr2
  3283.         lea    buffer+100(a4),a2
  3284. ctw1        move.l    (a2)+,a3
  3285.         addq.l    #4,a3
  3286. ctw6        move.l    (a3),d1
  3287.         move.l    d1,a3
  3288.         beq.s     ctw4
  3289.         move.l    86(a3),a0
  3290.         move.l    16(a0),d1
  3291.         cmp.l    d0,d1
  3292.         bne.s     ctw6
  3293.         move.l    d0,d1
  3294.         move.l    a3,d0
  3295.         bsr.s    windowoff
  3296.         move.l    d1,d0
  3297.         bra.s     ctw0
  3298. ctw4        dbra    d5,ctw1
  3299.         movem.l    (sp)+,d1-d7/a0-a6
  3300.         rts
  3301.  
  3302. ;Change the font for xopers window
  3303.  
  3304. myfont        moveq    #1,d5
  3305.         bra.s    setfon1
  3306.  
  3307. ;Change the font of a specified Window
  3308.  
  3309. setfont        moveq    #0,d5
  3310.  
  3311. setfon1        bsr.s    openfont
  3312.         tst.b    d2
  3313.         beq.s    1$            ; result not ok
  3314.         tst.w    d5
  3315.         bne.s    3$            ; our window
  3316.         move.l    d0,-(sp)
  3317.         move.l    a3,a0
  3318.         bsr    kllblnks
  3319.         bsr    getwnptr
  3320.         move.l    (sp)+,d0
  3321.         move.l    gfxbase(a4),a6        ; preload a6
  3322.         move.l    a3,d1
  3323.         beq.s    2$            ; no window
  3324.         cmp.l    wnptr(a4),a3
  3325.         beq.s    3$            ; xopers window
  3326.         move.l    d0,a0
  3327.         move.l    50(a3),a1
  3328.         RECALL    SetFont
  3329.         move.l    a3,a0
  3330.         CALL    RefreshWindowFrame,intuibase(a4)
  3331.         bra.s    1$
  3332. 3$        move.l    ownfont(a4),-(sp)    ; set font for Xoper
  3333.         move.l    d0,ownfont(a4)
  3334.         clr.b    topaz(a4)        ; use this font !
  3335.         bsr    usetopaz2
  3336.         move.l    (sp)+,d0
  3337.         beq.s    1$            ; no old font
  3338. 2$        move.l    d0,a1
  3339.         RECALL    CloseFont        ; no window or old xoper font
  3340. 1$        rts
  3341.  
  3342. ;Open a requested font
  3343.  
  3344. openfont    bsr    nodenam
  3345.         tst.b    0(a5)
  3346.         beq    3$            ; error
  3347.         tst.w    d5
  3348.         beq.s    14$            ; not myfont
  3349.         lea    deffont(a4),a0
  3350.         move.l    a5,a1
  3351.         bsr    strcmp            ; use "default" ?
  3352.         beq.s    15$
  3353.         sub.b    #$20,d0
  3354.         bne.s    14$
  3355. 15$        subq.w    #7,d1
  3356.         seq    d2            ; set as flag
  3357.         beq    1$            ; len was 7 !
  3358. 14$        move.l    a5,a3
  3359. 12$        cmp.b    #33,(a3)+
  3360.         bge.s    12$
  3361.         tst.b    -(a3)
  3362.         bne.s    11$            ; ok
  3363.         tst.w    d5
  3364.         beq    3$            ; error
  3365. 11$        clr.b    (a3)+
  3366.         lea    -6(a3),a0        ; check for '.font'
  3367.         lea    fontsuf(a4),a1
  3368.         bsr    strcmp
  3369.         beq.s    8$            ; correct suffix
  3370.         move.l    a5,a0
  3371.         lea    dummy(a4),a5
  3372.         move.l    a5,a2
  3373. 10$        move.b    (a0)+,(a2)+        ; copy fontname
  3374.         bne.s    10$
  3375.         subq.w    #1,a2
  3376. 9$        move.b    (a1)+,(a2)+        ; copy suffix
  3377.         bne.s    9$
  3378. 8$        lea    out-4(a4),a2
  3379.         move.l    a2,a0
  3380.         move.l    a5,(a0)+        ; +0
  3381.         move.w    procnum(a4),d2
  3382.         cmp.w    #7,d2
  3383.         bcc.s    7$            ; not smaller than 7 pixels !
  3384.         moveq    #7,d2
  3385. 7$        move.w    d2,(a0)+        ; +4
  3386.         clr.w    (a0)            ; +6
  3387.         move.l    a2,a0            ; TextAttr
  3388.         CALL    OpenFont,gfxbase(a4)
  3389.         move.l    d0,d4
  3390.         beq.s    6$
  3391.         move.l    d4,a0
  3392.         cmp.w    20(a0),d2        ; tf_YSize == ta_YSize ?
  3393.         beq.s    4$
  3394. 6$        lea     diskfont(a4),a1
  3395.         CALL    OldOpenLibrary,sysbase(a4)
  3396.         move.l    d0,d6
  3397.         beq.s    4$
  3398.         move.l    a2,a0            ; TextAttr
  3399.         CALL    OpenDiskFont,d6
  3400.         move.l    d0,d3
  3401.         beq.s    5$            ; no disk font
  3402.         exg.l    d3,d4
  3403.         move.l    d3,a1
  3404.         move.l    a1,d3
  3405.         beq.s    5$
  3406.         CALL    CloseFont,gfxbase(a4)    ; close font1
  3407. 5$        move.l    d6,a1
  3408.         CALL    CloseLibrary,sysbase(a4)
  3409. 4$        move.l    d4,d0            ; return font
  3410.         sne    d2            ; set as flag
  3411.         bne.s    1$
  3412.         move.w    #fonterr,d0        ; arrgh, no font found
  3413.         bsr    putstrw
  3414.         move.l    0(a2),d0        ; TextAttr->FontName
  3415.         bsr    putnam
  3416.         bra.s    1$
  3417. 3$        bsr    syntax            ; syntax error
  3418. 1$        rts
  3419.  
  3420. ;display loaded font names and definitions
  3421.  
  3422. fonts        lea    fohead(a4),a0
  3423.         bsr    puthead
  3424.         move.l    gfxbase(a4),a1
  3425.         lea    140(a1),a1        ; system fontlist
  3426. fo1        move.l    0(a1),a1
  3427.         tst.l    0(a1)
  3428.         beq.s    fo3
  3429.         bsr.s    fontdata
  3430.         bra.s    fo1
  3431. fo3        rts
  3432.  
  3433. fontdata    move.l    a1,d0
  3434.         move.l    d0,node(a4)
  3435.         bsr    hexa
  3436.         move.w    30(a1),d3
  3437.         bsr    worddec
  3438.         move.w    20(a1),d3
  3439.         bsr    worddec
  3440.         move.w    24(a1),d3
  3441.         bsr    worddec
  3442.         move.w    #romfnt,d0
  3443.         btst    #1,23(a1)
  3444.         beq.s    fod1
  3445.         addq.w    #diskfnt-romfnt,d0
  3446. fod1        bsr    putstrw
  3447.         move.w    #ffixed,d0
  3448.         btst    #5,23(a1)
  3449.         beq.s    1$
  3450.         addq.w    #fprop-ffixed,d0
  3451. 1$        bsr    putstrw
  3452.         move.b    32(a1),d3
  3453.         bsr    bytedec
  3454.         move.b    33(a1),d3
  3455.         bsr    bytedec
  3456.         move.l    10(a1),d0
  3457.         bra    putnam
  3458.  
  3459. ;set update rate
  3460.  
  3461. settime        bsr    getfrac
  3462.         tst.b    d7
  3463.         bne.s    st1
  3464.         move.w    #whattime,d0
  3465.         bsr    putstrw
  3466.         move.l    timeoutm(a4),d0
  3467.         move.l    #100000,d1
  3468.         bsr    div
  3469.         moveq    #0,d1
  3470.         move.b    timeout(a4),d1
  3471.         mulu    #10,d1
  3472.         add.l    d1,d0
  3473.         bne.s    1$
  3474.         move.w    #timenotset,d0
  3475.         bra    putnamw
  3476. 1$        bsr    putfrac
  3477.         bra    newline
  3478.  
  3479. st1        divs    #10,d2
  3480.         move.b    d2,timeout(a4)
  3481.         swap    d2
  3482.         ext.l    d2
  3483.         moveq    #0,d3
  3484.         subq.w    #1,d2
  3485.         bmi.s    1$
  3486. 2$        add.l    #100000,d3
  3487.         dbra    d2,2$
  3488. 1$        move.l    d3,timeoutm(a4)
  3489.         rts
  3490.  
  3491. zerotimer    bsr    nodenam
  3492.         moveq    #2,d7
  3493.         lea    TRuNode(pc),a3
  3494.         bsr    findnam
  3495.         tst.b    d7
  3496.         beq.s    1$
  3497.         bsr    gettimeentry
  3498.         lea    usedtime(a4),a0
  3499.         clr.l    0(a0,d0)
  3500. 1$        rts
  3501.  
  3502. ;cancel a task or a process. The theory is quite simple:
  3503. ;(Process->ReturnAddr)-4 points to the return address on
  3504. ;the stack. Task->SPReg points to the next instruction
  3505. ;to be executed. We just need a
  3506. ; *(Task->SPReg) = *(Process->ReturnAddr-4).
  3507. ;If the process has been started from Dos (CLI) and
  3508. ;the process is doing disk I/O, the CLI will respond with
  3509. ;a GURU #87000004 (AsyncPKT=unexpected packed received).
  3510. ;Thats why the calling CLI is also canceled.
  3511.  
  3512. cancel        tst.b    fromfile(a4)
  3513.         beq.s    cancel1
  3514.         rts
  3515. cancel1     clr.l    remembr(a4)        ; used for CLI stdio
  3516.         clr.l    remembr2(a4)
  3517.         clr.b    bool(a4)
  3518.         bsr    nodenam
  3519. testagain    moveq    #1,d7
  3520.         lea    TReNode(pc),a3
  3521.         bsr    findnam
  3522.         tst.b    d7
  3523.         bne.s    canok
  3524. cnerr        move.w    #stperr,d0
  3525.         bra    putnamw
  3526.  
  3527. canok        moveq    #0,d5
  3528. canok2        move.l    d0,pointer(a4)        ; d0=task
  3529.         move.l    d0,a1
  3530.         cmp.b    #1,8(a1)        ; TASK ?
  3531.         bne.s    isproc
  3532.         CALL    RemTask,sysbase(a4)
  3533.         move.l    pointer(a4),d0
  3534.         bsr    closetsports
  3535.         move.l    pointer(a4),d0
  3536.         bra    closetskwin
  3537.  
  3538. isproc        tst.w    d5
  3539.         bne.s    isproc2            ; second try !
  3540.         movem.l    d0-d7/a0-a6,-(sp)
  3541.         moveq    #-1,d0            ; needed for recursive killing tasks
  3542.         CALL    AllocSignal,sysbase(a4)
  3543.         move.b    d0,cancelsig(a4)
  3544.         moveq    #0,d1
  3545.         bset    d0,d1
  3546.         move.l    d1,cancelmask(a4)
  3547.         movem.l    (sp)+,d0-d7/a0-a6
  3548.  
  3549. isproc2        moveq    #0,d5
  3550.         tst.l    172(a1)            ; pr_CLI
  3551.         beq.s    wascreproc
  3552.         move.l    $80(a1),a2        ; Seglist
  3553.         adda.l    a2,a2
  3554.         adda.l    a2,a2
  3555.         move.l    12(a2),d1        ; empty ?
  3556.         bne.s    wascreproc
  3557.         move.l    172(a1),a2        ; CommandLineInterface
  3558.         adda.l    a2,a2
  3559.         adda.l    a2,a2
  3560.         move.l    60(a2),d5        ; cli_Module
  3561.         tst.l    40(a2)            ; IsInteractive
  3562.         beq    dosreturn
  3563.         move.l    28(a2),remembr(a4)    ; yes,get Cli-Window locks
  3564.         move.l    56(a2),remembr2(a4)
  3565.         bra    dosreturn
  3566. wascreproc    tst.b    bool(a4)        ; it is not a CLI, ask what to do
  3567.         bne.s    unload
  3568.         move.b    #3,bool(a4)
  3569.         bsr    ResumeOutput
  3570.         move.w    #canerr0,d0        ; ask for Workbench
  3571.         bsr    putstrw
  3572.         bsr    readline
  3573.         cmp.b    #'y',d0
  3574.         beq.s    andagain
  3575.         move.b    #2,bool(a4)
  3576.         bsr    ResumeOutput
  3577.         move.w    #canerr1,d0        ; ask for unload
  3578.         bsr    putstrw
  3579.         bsr    readline
  3580.         cmp.b    #'y',d0
  3581.         bne.s    andagain
  3582.         move.b    #1,bool(a4)
  3583. andagain    move.l    pointer(a4),d0
  3584.         moveq    #1,d7
  3585.         lea    TReNode(pc),a3
  3586.         bsr    tstnode
  3587.         tst.w    d5
  3588.         beq    cnerr
  3589.         bra    canok2
  3590.  
  3591. unload        move.l    128(a1),d0        ; get Segmentlist
  3592.         beq.s    ulerr
  3593.         lsl.l    #2,d0
  3594.         move.l    d0,a3
  3595.         moveq    #2,d0
  3596.         cmp.l    0(a3),d0
  3597.         bgt.s    ulerr
  3598.         move.l    12(a3),d4
  3599.         bne.s    unl4
  3600. ulerr        move.w    #unloaderr,d0        ; no Segments !?
  3601.         bra    putnamw
  3602.  
  3603. unl4        cmp.b    #3,bool(a4)        ; Workbench Task
  3604.         bne.s    unl2
  3605.         move.l    a1,-(sp)
  3606.         moveq    #40,d0            ; build a copy of the
  3607.         move.l    pubclr(a4),d1        ; Workbench startup-message
  3608.         CALL    AllocMem,sysbase(a4)
  3609.         move.l    d0,startmess(a4)
  3610.         move.l    d0,a0
  3611.         move.l    a0,-(sp)
  3612.         move.b    #5,8(a0)
  3613.         move.w    #20,18(a0)
  3614.         move.l    d4,24(a0)
  3615.         moveq    #92,d0
  3616.         add.l    4(sp),d0
  3617.         move.l    d0,20(a0)
  3618.         lea    wbportnam(a4),a1
  3619.         RECALL    FindPort
  3620.         movem.l    (sp)+,a0/a1
  3621.         move.l    d0,14(a0)
  3622.         bne.s    unl2
  3623.         move.w    #noworkbench,d0
  3624.         bra    putnamw
  3625.  
  3626. unl2        cmp.b    #1,bool(a4)
  3627.         bne.s    dosreturn
  3628.         move.l    a1,-(sp)        ; unload process manualy
  3629.         move.l    d4,d1
  3630.         CALL    UnLoadSeg,dosbase(a4)
  3631.         move.l    (sp)+,a1
  3632.  
  3633. dosreturn    move.l    140(a1),savedat(a4)    ; Processnumber
  3634. dosret1        move.w    #$4000,$dff09a
  3635.         move.l    54(a1),a3
  3636.         lea    endtask(pc),a0
  3637.         move.l    a0,0(a3)
  3638.         tst.b    gotguru(a4)
  3639.         bne.s    1$
  3640.         tst.b    bool(a4)
  3641.         bne.s    1$
  3642.         move.b    #2,106(a1)        ; ignore messages
  3643. 1$        cmp.b    #4,15(a1)        ; if waiting
  3644.         bne.s    doswait
  3645.         move.l    a1,d4
  3646.         CALL    Remove,sysbase(a4)
  3647.         move.l    d4,a1
  3648.         lea    406(a6),a0        ; activate the task
  3649.         RECALL    AddHead
  3650.         move.l    d4,a1
  3651.  
  3652. doswait        move.w    #$C000,$dff09a
  3653.  
  3654.         tst.b    bool(a4)
  3655.         bne.s    endnodos
  3656.         tst.l    d5
  3657.         beq.s    endcanc
  3658.  
  3659.         move.l    172(a1),a2
  3660.         adda.l    a2,a2
  3661.         adda.l    a2,a2
  3662. dwa1        movem.l    d0-d7/a0-a6,-(sp)
  3663.         move.l    cancelmask(a4),d0
  3664.         CALL    Wait,sysbase(a4)
  3665.         movem.l    (sp)+,d0-d7/a0-a6
  3666.         tst.b    gotguru(a4)
  3667.         bne.s    endnodos
  3668.         moveq    #0,d5
  3669.         bra.s    dosret1
  3670.  
  3671. endcanc        move.l    a1,-(sp)
  3672.         move.l    dosbase(a4),a6
  3673.         move.l    remembr(a4),d1        ; close CLI-Window
  3674.         beq.s    ecan1            ; if any
  3675.         RECALL    Close
  3676. ecan1        move.l    remembr2(a4),d1
  3677.         beq.s    ecan2
  3678.         RECALL    Close
  3679. ecan2        move.l    (sp)+,a1
  3680.  
  3681.         move.l    savedat(a4),d0        ; remove Task from
  3682.         move.l    dosbase(a4),a2        ; TaskArray
  3683.         move.l    34(a2),a2
  3684.         move.l    0(a2),a2
  3685.         adda.l    a2,a2
  3686.         adda.l    a2,a2
  3687.         lsl.l    #2,d0
  3688.         clr.l    0(a2,d0)
  3689.  
  3690. endnodos    move.l    a1,d0
  3691.         bsr    closetskwin
  3692.         move.l    a1,d0
  3693.         bsr    closetsports
  3694.         moveq    #0,d0
  3695.         move.b    cancelsig(a4),d0    ; remove our Signal
  3696.         CALL    FreeSignal,sysbase(a4)
  3697.         rts
  3698.  
  3699. ;This Code is (hopefully) executed by the Process we want to kill
  3700.  
  3701. endtask        lea    dataarea(pc),a4
  3702.         move.l    sysbase(a4),a6
  3703.         move.l    276(a6),a1
  3704.         move.l    176(a1),a1        ; Process_ReturnAddr
  3705.         lea    -4(a1),sp        ; reset Process Stackptr
  3706.         tst.b    bool(a4)
  3707.         bne.s    et0
  3708.         movea.l    mytask(a4),a1
  3709.         move.l    cancelmask(a4),d0    ; signal Xoper it
  3710.         RECALL    Signal            ; died
  3711. et0        cmp.b    #3,bool(a4)        ; Workbench Process ?
  3712.         bne.s    et1
  3713.         RECALL    Forbid
  3714.         move.l    startmess(a4),a1
  3715.         RECALL    ReplyMsg        ; reply startup message
  3716. et1        rts
  3717.  
  3718. ;Stop a task (just queue it on a special list)
  3719.  
  3720. freeze        bsr    nodenam
  3721.         moveq    #1,d7
  3722.         lea    TReNode(pc),a3
  3723.         bsr    findnam
  3724.         tst.b    d7
  3725.         bne.s    frok
  3726. frerr        move.w    #stperr,d0
  3727.         bra    putstrw
  3728. frok        move.l    d0,a1
  3729.         cmp.b    #13,8(a1)
  3730.         beq.s    1$
  3731.         cmp.b    #1,8(a1)
  3732.         bne.s    frerr
  3733. 1$        move.w    #$4000,$dff09a
  3734.         CALL    Remove,sysbase(a4)
  3735.         move.w    #$C000,$dff09a
  3736.         move.l    d0,a1
  3737.         move.l    d0,a5
  3738.         lea     stplist(a4),a0
  3739.         RECALL    AddHead
  3740.         add.b    #4,15(a5)
  3741.         rts
  3742.  
  3743. ;put the task back on its list
  3744.  
  3745. warm        bsr    nodenam
  3746.         cmp.b    #'$',0(a5)
  3747.         bne.s    1$
  3748.         move.l    d7,d2
  3749.         move.l    a5,a0
  3750.         bsr    readhex
  3751.         tst.b    d7
  3752.         beq.s    1$
  3753.         move.l    stplist(a4),a3
  3754. 3$        tst.l    0(a3)
  3755.         beq.s    2$
  3756.         cmp.l    a3,d0
  3757.         beq.s    waok
  3758.         move.l    0(a3),a3
  3759.         bra.s    3$
  3760. 1$        lea    stplist(a4),a0
  3761.         movea.l    a5,a1
  3762.         moveq    #0,d7
  3763.         bsr    fn4
  3764.         tst.b    d7
  3765.         bne.s    waok
  3766. 2$        move.w    #waerr,d0
  3767.         bra    putstrw
  3768. waok        move.w    #$4000,$dff09a
  3769.         move.l    d0,a1
  3770.         CALL    Remove,sysbase(a4)
  3771.         move.l    d0,a1
  3772.         move.l    d0,a5
  3773.         move.l    TReNode(pc),a0
  3774.         cmp.b    #8,15(a1)
  3775.         bne.s    2$
  3776.         move.l    TWaNode(pc),a0
  3777. 2$        adda.l    a6,a0
  3778.         RECALL    AddTail
  3779.         move.l    d0,a1
  3780.         subq.b    #4,15(a5)
  3781.         move.w    #$C000,$dff09a
  3782.         move.l    18(a5),d0
  3783.         and.l    26(a5),d0
  3784.         beq.s    1$
  3785.         movea.l    a5,a1
  3786.         RECALL    Signal
  3787. 1$        rts
  3788.  
  3789. ;show the hunks of a process
  3790. hunks        bsr    nodenam
  3791.         moveq    #2,d7
  3792.         lea    TRuNode(pc),a3
  3793.         bsr    findnam
  3794.         tst.b    d7
  3795.         bne.s    hu1
  3796.         rts
  3797. hu1        move.l    d0,a5
  3798.         move.w    #noprocs,d0
  3799.         cmp.b    #13,8(a5)
  3800.         bne.s    hu4            ; not a process
  3801.         move.w    #unloaderr,d7
  3802.         move.l    128(a5),d0        ; pr_SegList
  3803.         move.l    172(a5),d1
  3804.         beq.s    hu2            ; not a CLI
  3805.         lsl.l    #2,d1
  3806.         move.l    d1,a5
  3807.         move.l    60(a5),d1
  3808.         bne.s    hu5            ; valid seglist
  3809.         moveq    #0,d7
  3810. hu2        move.l    d0,d1
  3811.         beq.s    hu3            ; no segments
  3812.         lsl.l    #2,d1
  3813.         move.l    d1,a5
  3814.         moveq    #2,d1            ; index >= 2 ?
  3815.         cmp.l    0(a5),d1
  3816.         bgt.s    hu3            ; no segments
  3817.         move.l    12(a5),d1
  3818.         beq.s    hu3            ; no segments
  3819.         move.w    #segloaded,d0
  3820.         bsr.s    hu4            ; CreateProc()
  3821.         bra.s    hu6
  3822.  
  3823. hu3        move.w    d7,d0
  3824.         bne.s    hu4            ; no seglist found
  3825.         move.w    #cliprocs,d0
  3826.         bsr    putnamw
  3827.         move.w    #notload,d0        ; empty CLI
  3828. hu4        bra    putnamw
  3829.  
  3830. hu5        move.w    #cliprocs,d0
  3831.         bsr    putnamw
  3832.         move.w    #procloaded,d0
  3833.         bsr    putstrw
  3834.         move.l    16(a5),d0        ; cli_CommandName
  3835.         bsr    putbcpl
  3836.         bsr    newline
  3837. hu6        lea    hunkheader(a4),a0
  3838.         bsr    puthead
  3839.         moveq    #0,d5
  3840. hu7        move.l    d5,d3
  3841.         bsr    bytedec
  3842.         addq.l    #1,d5
  3843.         move.l    d1,d0
  3844.         bsr    hexa
  3845.         lsl.l    #2,d1
  3846.         move.l    d1,a5
  3847.         moveq    #4,d0
  3848.         add.l    d1,d0
  3849.         bsr    hexa
  3850.         move.l    -4(a5),d0
  3851.         moveq    #1,d3
  3852.         bsr    longdec
  3853.         move.l    #'($',d0
  3854.         bsr    putlongascii
  3855.         move.l    -4(a5),d0
  3856.         bsr    hexa
  3857.         subq.l    #1,ptr(a4)
  3858.         moveq    #')',d0
  3859.         bsr    putchar
  3860.         bsr    newline
  3861.         move.l    0(a5),d1
  3862.         bne.s    hu7
  3863.         rts
  3864.  
  3865. ;change the priority of a node
  3866.  
  3867. pri        bsr    getnum
  3868.         tst.b    d7
  3869.         beq    syntax
  3870.         move.b    d2,newpri(a4)
  3871.         bsr    nodenam2
  3872.         moveq    #8,d7
  3873.         lea    TRuNode(pc),a3
  3874.         bsr    findnam
  3875.         tst.b    d7
  3876.         beq.s    pi1
  3877.         move.l    d0,a1
  3878.         cmp.b    #13,8(a1)
  3879.         beq.s    tp2
  3880.         cmp.b    #1,8(a1)
  3881.         beq.s    tp2
  3882.         move.b    newpri(a4),9(a1)
  3883.         lea    SemNode(pc),a0
  3884.         cmp.l    a0,a3
  3885.         ble.s    pi2
  3886.         move.w    #listerr,d0
  3887.         bra    putnamw
  3888. pi2        CALL    Forbid,sysbase(a4)
  3889.         RECALL    Remove
  3890.         move.l    d0,a1
  3891.         movea.l    (a3),a0
  3892.         adda.l    a6,a0
  3893.         RECALL    Enqueue
  3894.         RECALL    Permit
  3895. pi1        rts
  3896.  
  3897. ;set the priority of our task
  3898.  
  3899. mypri        bsr    getnum
  3900.         tst.b    d7
  3901.         beq    syntax
  3902.         move.l    sysbase(a4),a1
  3903.         move.l    276(a1),a1
  3904.         move.l    d2,d0
  3905.         bra.s    tp3
  3906.  
  3907. ;modify a task's priority
  3908.  
  3909. taskpri        bsr    getnum
  3910.         tst.b    d7
  3911.         beq    syntax
  3912.         move.b    d2,newpri(a4)
  3913.         bsr    nodenam
  3914.         moveq    #2,d7
  3915.         lea    TRuNode(pc),a3
  3916.         bsr    findnam
  3917.         tst.b    d7
  3918.         beq.s    tp1
  3919.         move.l    d0,a1
  3920. tp2        move.b    newpri(a4),d0
  3921. tp3        CALL    SetTaskPri,sysbase(a4)
  3922. tp1        rts
  3923.  
  3924. ;set all break signals of a task
  3925.  
  3926. break        move.l    #$f000,d0
  3927.         bra.s    setthem
  3928.  
  3929. signal        bsr    readhex
  3930.         tst.b    d7
  3931.         beq    syntax
  3932. setthem     move.l    d0,savedat(a4)
  3933.         bsr    nodenam
  3934.         moveq    #2,d7
  3935.         lea    TReNode(pc),a3
  3936.         bsr    findnam
  3937.         tst.b    d7
  3938.         beq.s    1$
  3939.         move.l    d0,a1
  3940.         move.l    savedat(a4),d0
  3941.         and.l    18(a1),d0
  3942.         CALL    Signal,sysbase(a4)
  3943. 1$        rts
  3944.  
  3945. ;set up a list of tasknames which should't be displayed
  3946.  
  3947. hide        cmp.b    #10,0(a0)
  3948.         bne.s    hid5
  3949.         bra    syntax
  3950. hid5        lea    hidestart(a4),a2
  3951.         move.l    a2,d3
  3952. hid0        tst.l    0(a2)
  3953.         beq.s    hid1
  3954.         move.l    0(a2),a2
  3955.         lea    4(a2),a1
  3956.         bsr    strcmp
  3957.         beq.s    hid2
  3958.         move.l    a2,d3
  3959.         bra.s    hid0
  3960. hid1        move.l    a0,a3
  3961.         moveq    #10,d0
  3962.         bsr    strlen2
  3963.         addq.l    #5,d0
  3964.         moveq    #1,d1
  3965.         swap    d1
  3966.         CALL    AllocMem,sysbase(a4)
  3967.         move.l    d0,a1
  3968.         move.l    a1,d0
  3969.         beq.s     hid4
  3970.         move.l    d0,0(a2)
  3971.         addq.l    #4,a1
  3972. hid3        cmp.b    #10,0(a3)
  3973.         beq.s    hid4
  3974.         move.b    (a3)+,(a1)+
  3975.         bra.s    hid3
  3976. hid4        rts
  3977. hid2        move.l    d3,a3
  3978.         move.l    0(a2),0(a3)
  3979. freehidden    lea    4(a2),a0
  3980.         bsr    strlen
  3981.         addq.l    #5,d0
  3982.         move.l    a2,a1
  3983.         move.l    sysbase(a4),a6
  3984.         jmp    _LVOFreeMem(a6)
  3985.  
  3986. freehidmem    move.l    hidestart(a4),d0
  3987.         beq.s    1$
  3988. 2$        move.l    d0,a2
  3989.         move.l    0(a2),a3
  3990.         bsr.s    freehidden
  3991.         move.l    a3,d0
  3992.         bne.s    2$
  3993. 1$        rts
  3994.  
  3995. hideit        tst.b    hideon(a4)
  3996.         beq.s    pt76
  3997.         lea    hidestart(a4),a3
  3998.         move.l    4(a5),a0
  3999. pt74        tst.l    0(a3)
  4000.         beq.s    pt76
  4001.         move.l    0(a3),a3
  4002.         lea    4(a3),a1
  4003.         bsr    strcmp
  4004.         bne.s    pt74
  4005.         rts
  4006. pt76         moveq    #1,d0
  4007.         rts
  4008.  
  4009. ;set up an ALIAS list
  4010.  
  4011. alias        cmp.b    #10,0(a0)
  4012.         beq    showalias
  4013.         bsr    strbuf
  4014.         lea    buffer(a4),a3
  4015.         move.l    a0,a5
  4016.         move.l    a3,a0
  4017.         bsr    strlen
  4018.         tst.l    d0
  4019.         beq    syntax
  4020.  
  4021.         cmp.w    #1,d0
  4022.         bne.s    5$
  4023.         lea    params(a4),a0
  4024.         moveq    #parmnum-1,d1
  4025.         move.b    0(a3),d2
  4026. 6$        cmp.b    (a0)+,d2
  4027.         dbeq    d1,6$
  4028.         bne.s    5$
  4029.         move.w     #aliaserr,d0
  4030.         bsr    putstrw
  4031.         move.w    #params,d0
  4032.         bsr    putstrw
  4033.         move.w    #aliaserr2,d0
  4034.         bra    putnamw
  4035.  
  4036. 5$        move.l    d0,d5
  4037.         bsr    findalias
  4038.         tst.l    d2
  4039.         bmi.s    7$            ; no alias
  4040.         lea    aliaslist(a4),a0
  4041.         cmp.l    (a0),a2
  4042. 10$        beq.s    9$
  4043.         move.l    (a0),a0
  4044.         bra.s    10$
  4045. 9$        move.l    (a2),(a0)
  4046.         lea    5(a2),a0
  4047. 8$        tst.b    (a0)+
  4048.         bne.s    8$
  4049.         move.l    a0,d0
  4050.         move.l    a2,a1
  4051.         sub.l    a1,d0
  4052.         CALL    FreeMem,sysbase(a4)
  4053.         cmp.b    #10,0(a5,d5.l)
  4054.         beq.s    1$            ; was 'unalias'
  4055.  
  4056. 7$        lea    0(a5,d5.l),a0
  4057.         bsr    kllblnks
  4058.         bsr    findcmd
  4059.         tst.l    d2
  4060.         bmi    syntax
  4061.         move.l    a5,a0
  4062.         bsr    strbuf
  4063.  
  4064.         addq.l    #6,d5
  4065.         move.l    d5,d0
  4066.         moveq    #1,d1
  4067.         swap    d1
  4068.         CALL    AllocMem,sysbase(a4)
  4069.         tst.l    d0
  4070.         beq.s    1$
  4071.  
  4072.         lea    aliaslist(a4),a0
  4073. 2$        move.l    (a0),d1
  4074.         beq.s    3$
  4075.         move.l    d1,a0
  4076.         bra.s    2$
  4077. 3$        move.l    d0,0(a0)
  4078.  
  4079.         move.l    d0,a0
  4080.         move.b    d2,4(a0)
  4081.  
  4082.         addq.w    #5,a0
  4083. 4$        move.b    (a3)+,(a0)+
  4084.         bne.s    4$
  4085. 1$        rts
  4086.  
  4087. showalias    lea    alhead(a4),a0
  4088.         bsr    puthead
  4089.         move.l    aliaslist(a4),d0
  4090.         beq.s    1$
  4091. 2$        move.l    d0,a5
  4092.         addq.l    #5,d0
  4093.         bsr    putstr
  4094.         move.w    #15,d1
  4095.         bsr    tab
  4096.         move.w    #equal,d0
  4097.         bsr    putstrw
  4098.         move.b    4(a5),d0
  4099.         ext.w    d0
  4100.         bsr.s    getcmdptr
  4101.         bsr    putnam
  4102.         move.l    0(a5),d0
  4103.         bne.s    2$
  4104. 1$        rts
  4105.  
  4106. freealias    move.l    aliaslist(a4),d0
  4107.         beq.s    1$
  4108. 2$        move.l    d0,a2
  4109.         move.l    0(a2),a3
  4110.         lea    5(a2),a0
  4111.         bsr    strlen
  4112.         addq.l    #6,d0
  4113.         move.l    a2,a1
  4114.         CALL    FreeMem,sysbase(a4)
  4115.         move.l    a3,d0
  4116.         bne.s    2$
  4117. 1$        rts
  4118.  
  4119. getcmdptr    move.l    a0,-(sp)
  4120.         lea    commds(a4),a0
  4121. 2$        subq.w    #1,d0
  4122.         bcs.s    1$
  4123. 3$        tst.b    (a0)+
  4124.         bne.s    3$
  4125.         bra.s    2$
  4126. 1$        move.l    a0,d0
  4127.         move.l    (sp)+,a0
  4128.         rts
  4129.  
  4130. ;add a fkey definition to the fkey list. Each entry
  4131. ;looks like this: long Succ, long Pred, byte Key#, byte length,
  4132. ;          char text[]
  4133.  
  4134. showfkeys    lea    fkhead(a4),a0
  4135.         bsr    puthead
  4136.         lea    fkeys(a4),a1
  4137. 1$        move.l    0(a1),a1
  4138.         tst.l    0(a1)
  4139.         beq.s    2$
  4140.         moveq    #'F',d0
  4141.         bsr    putchar
  4142.         moveq    #1,d3
  4143.         add.b    8(a1),d3
  4144.         bsr    bytedec
  4145.         move.b    9(a1),d1
  4146.         subq.b    #1,d1
  4147.         lea    10(a1),a2
  4148. 3$        move.b    (a2)+,d0
  4149.         bsr    putchar
  4150.         subq.b    #1,d1
  4151.         bcc.s    3$            ; dbra for bytes ...
  4152.         bsr    newline
  4153.         bra.s    1$
  4154. 2$        rts
  4155.  
  4156. setfkey        bsr    nodenam
  4157.         move.w    procnum(a4),d5
  4158.         beq.s    showfkeys
  4159.         cmp.w    #21,d5
  4160.         bcc    syntax
  4161.         subq.w    #1,d5
  4162.         move.w    d5,procnum(a4)
  4163.         move.l    sysbase(a4),a6
  4164.         lea    fkeys(a4),a1
  4165. 1$        move.l    0(a1),a1
  4166.         tst.l    0(a1)
  4167.         beq.s    2$
  4168.         cmp.b    8(a1),d5
  4169.         bne.s    1$
  4170.         move.l    a1,d3
  4171.         RECALL    Remove
  4172.         move.l    d3,a1
  4173.         bsr.s    removefkey
  4174. 2$        tst.b    0(a5)
  4175.         beq.s    4$
  4176.         move.l    a5,a0
  4177.         bsr    strlen
  4178.         move.l    d0,d5
  4179.         add.w    #10,d0
  4180.         moveq    #0,d1
  4181.         RECALL    AllocMem
  4182.         move.l    d0,a1
  4183.         move.l    a1,d0
  4184.         beq.s    4$
  4185.         move.l    d0,a3
  4186.         move.b    procnum+1(a4),8(a1)
  4187.         move.b    d5,9(a1)
  4188.         lea    fkeys(a4),a0
  4189.         RECALL    AddHead
  4190.         lea    10(a3),a3
  4191.         subq.w    #1,d5
  4192. 3$        move.b    (a5)+,(a3)+
  4193.         dbeq    d5,3$
  4194. 4$        rts
  4195.  
  4196. clrfkeys    move.l    sysbase(a4),a6
  4197. 2$        lea    fkeys(a4),a0
  4198.         RECALL    RemHead
  4199.         move.l    d0,a1
  4200.         move.l    a1,d0
  4201.         beq.s    1$
  4202.         bsr.s    removefkey
  4203.         bra.s    2$
  4204. 1$        rts
  4205.  
  4206. removefkey    move.b    9(a1),d0        ; length
  4207.         ext.w    d0
  4208.         ext.l    d0
  4209.         add.w    #10,d0
  4210.         jmp    _LVOFreeMem(a6)
  4211.  
  4212. ;'flushlibs'
  4213.  
  4214. flush        moveq    #-1,d0
  4215.         moveq    #0,d1
  4216.         move.l    sysbase(a4),a6
  4217.         jmp    _LVOAllocMem(a6)
  4218.  
  4219. ;display library->lib_IDString
  4220.  
  4221. info        bsr    nodenam2
  4222.         moveq    #2,d7
  4223.         lea    DevNode(pc),a3
  4224.         bsr    findnam
  4225.         tst.b    d7
  4226.         beq.s    removefkey-2        ; hack !
  4227.         move.l    d0,a0
  4228.         move.l    24(a0),d0
  4229.         beq.s    if2
  4230.         move.l    d0,a0
  4231.         tst.b    (a0)
  4232.         bne.s    if1
  4233. if2        move.w    #noinfo,d0
  4234.         bsr    putstrw
  4235.         move.l    a5,d0
  4236. if1        bra    putnam
  4237.  
  4238. ; reset vectors
  4239.  
  4240. capture        move.l    sysbase(a4),a1
  4241.         lea     42(a1),a0
  4242.         moveq    #2,d6
  4243.         lea    coldtxt(a4),a3
  4244. cap0        move.l    a3,d0
  4245.         bsr    putstr
  4246.         move.l    (a0)+,d0
  4247.         bne.s    cap1
  4248.         move.w    #unset,d0
  4249.         bsr    putstrw
  4250.         bra.s    cap2
  4251. cap1        bsr    hexa
  4252. cap2        bsr    newline
  4253.         lea     15(a3),a3
  4254.         dbra    d6,cap0
  4255.         move.w    #kicktxt,d0
  4256.         bsr    putstrw
  4257.         move.l    546(a1),d0
  4258.         bne.s    kickm3
  4259.         move.w    #unset,d0
  4260.         bra    putnamw
  4261. kickm3        move.l    d0,-(sp)
  4262.         bsr    newline
  4263.         lea    kickhead(a4),a0
  4264.         bsr    puthead
  4265.         move.l    (sp)+,a0
  4266. kickm0        move.l    a0,d0
  4267.         beq.s    kickm4
  4268.         bpl.s    kickm1
  4269.         bclr    #31,d0
  4270.         move.l    d0,a0
  4271.         bra.s    kickm0
  4272. kickm1        move.w    14(a0),d6
  4273.         subq.w    #1,d6
  4274.         lea    16(a0),a2
  4275. kickm2        move.l    0(a2),d0
  4276.         bsr    hexa
  4277.         move.l    (a2)+,d0
  4278.         move.l    (a2)+,d4
  4279.         add.l    d4,d0
  4280.         bsr    hexa
  4281.         move.l    d4,d0
  4282.         moveq    #0,d3
  4283.         bsr    longdec
  4284.         bsr    newline
  4285.         dbra    d6,kickm2
  4286.         move.l    0(a0),a0
  4287.         bra.s    kickm0
  4288. kickm4        rts
  4289.  
  4290. clrcold        moveq    #42,d0
  4291.         bra.s    chksum
  4292. clrcool        moveq    #46,d0
  4293.         bra.s    chksum
  4294. clrwarm        moveq    #50,d0
  4295.  
  4296. chksum        move.l    sysbase(a4),a0
  4297.         clr.l    0(a0,d0.w)
  4298.         lea    34(a0),a1
  4299.         moveq    #22,d0
  4300. addchk        add.w    (a1)+,d1
  4301.         dbra     d0,addchk
  4302.         not.w    d1
  4303.         move.w    d1,82(a0)
  4304.         rts
  4305.  
  4306. ;Save the command line to be repeated. If this line doesn't produce
  4307. ;any output, don't repeat it at all
  4308. repeatcmd    not.b    repeat(a4)
  4309.         beq.s    3$
  4310.         move.w    repeatlen(a4),d0
  4311.         subq.w    #7,d0
  4312.         beq.s    4$
  4313.         move.w    d0,repeatlen(a4)
  4314.         lea    repeatbuffer(a4),a1
  4315.         lea    dummy(a4),a2
  4316.         move.w    d0,d1
  4317. 1$        move.b    0(a0),(a1)+
  4318.         move.b    (a0)+,(a2)+
  4319. 2$        dbra    d1,1$
  4320.         clr.l    lastprinted(a4)
  4321.         clr.b    printed(a4)
  4322.         bsr    cli
  4323.         tst.b    printed(a4)
  4324.         beq.s    4$
  4325.         bsr    starttimer
  4326. 3$        rts
  4327. 4$        clr.b    repeat(a4)
  4328.         bra.s    3$
  4329.  
  4330. ;save the parameters from a 'window x y width height' call
  4331. setwindow    tst.b    fromfile(a4)
  4332.         bne.s    wiw1
  4333. wiw3        move.w    #wiwerr,d0
  4334.         bra    putnamw
  4335. wiw1        lea    window_l(a4),a3
  4336.         moveq    #3,d5
  4337. wiw0        bsr    getnum
  4338.         tst.w    d7
  4339.         beq.s    wiw2
  4340.         move.w    d2,(a3)+
  4341.         dbra    d5,wiw0
  4342. wiw2        rts
  4343.  
  4344. iconpos        bsr    getnum            ; set icon position
  4345.         tst.w    d7
  4346.         beq.s    1$
  4347.         move.w    d2,-(sp)
  4348.         bsr    getnum
  4349.         swap    d2
  4350.         move.w    (sp)+,d2
  4351.         swap    d2            ; X.w,Y.w
  4352.         tst.w    d7
  4353.         beq.s    1$
  4354.         move.l    d2,icnwindow(a4)    ; store new pos
  4355. 1$        rts
  4356.  
  4357. iconbackdrp    eor.w    #$100,icnwindow+16(a4)    ; wn_Flags+2
  4358.         rts
  4359.  
  4360. ;toggle patchmode (ignore cmd if a setfunction manager is installed)
  4361. smartpatch    lea    setmannam(a4),a1    ; public manager port
  4362.         CALL    FindPort,sysbase(a4)
  4363.         tst.l    d0
  4364.         bne.s    smartpatch-2        ; hack !
  4365.         lea    patchmode(a4),a2
  4366.         bra.s    onoff
  4367.  
  4368. ;toggle commodity on/off
  4369. cxhandler    lea    cxstate(a4),a2
  4370.         bsr.s    onoff
  4371.         tst.b    fromfile(a4)
  4372.         bne.s    1$            ; script !
  4373.         bsr    setwintitle
  4374. 1$        rts
  4375.  
  4376. ;toggle TaskInfo
  4377. taskinfo    lea    tinfo(a4),a2
  4378.         bra.s    onoff
  4379.  
  4380. ;toggle CLI-Commands
  4381. clicmd        lea    cmdcli(a4),a2
  4382.         bra.s    onoff
  4383.  
  4384. ;toggle task-header display
  4385. nohead        lea    headon(a4),a2
  4386.         bra.s    onoff
  4387.  
  4388. ;toggle hide entries
  4389. hidden        lea    hideon(a4),a2
  4390.         bra.s    onoff
  4391.  
  4392. ;toggle sort on/off
  4393. sort        lea    sorton(a4),a2
  4394.         bra.s    onoff
  4395.  
  4396. ;toggle task-ports display
  4397. taskports    lea    tports(a4),a2
  4398.         bra.s    onoff
  4399.  
  4400. ;toggle CPUSE task list
  4401. usage        lea    useageon(a4),a2
  4402.  
  4403. ;test if 'on'(-1) or 'off'(0) was entered
  4404.  
  4405. onoff        bsr    kllblnks
  4406.         moveq    #0,d2
  4407.         lea    offstr(a4),a1
  4408.         bsr    strcmp
  4409.         beq.s    1$
  4410.         subq.b    #1,d2
  4411.         lea    onstr(a4),a1
  4412.         bsr    strcmp
  4413.         beq.s    1$
  4414.         eor.b    d2,0(a2)
  4415.         move.b    0(a2),d2
  4416. 1$        move.b    d2,0(a2)
  4417.         rts
  4418.  
  4419. ;toggle prop gadget on/off
  4420. propgad        moveq    #0,d7
  4421.         lea    propgadon(a4),a2
  4422.         lea    sbgadget(a4),a3
  4423.         bra.s    gadonoff
  4424.  
  4425. ;toggle iconify gadget on/off
  4426. icongad        moveq    #1,d7
  4427.         lea    iconifyon(a4),a2
  4428.         lea    iconifgad(a4),a3
  4429.  
  4430. gadonoff    move.b    (a2),-(sp)        ; save old state
  4431.         bsr.s    onoff
  4432.         move.b    (sp)+,d0
  4433.         tst.w    d7
  4434.         beq.s    3$            ; not iconify gadget
  4435.         tst.b    ownscreen(a4)
  4436.         bne.s    1$            ; only window valid
  4437.         tst.b    post_V34(a4)
  4438.         bne.s    1$            ; only pre Kick2.0+
  4439. 3$        tst.b    fromfile(a4)
  4440.         bne.s    1$            ; from file
  4441.         cmp.b    (a2),d0
  4442.         beq.s    1$            ; oldstate == newstate !
  4443.         move.l    intuibase(a4),a6
  4444.         move.w    #_LVORemoveGadget,d1
  4445.         tst.b    (a2)
  4446.         beq.s    2$
  4447.         move.w    #_LVOAddGadget,d1
  4448. 2$        moveq    #0,d0            ; top of list !
  4449.         move.l    wnptr(a4),a0
  4450.         move.l    a3,a1
  4451.         jsr    0(a6,d1.w)        ; RemoveGadget or AddGadget
  4452.         bsr    setupscreen
  4453. 1$        rts
  4454.  
  4455. ;Open a library
  4456. openlib        bsr    nodenam2
  4457.         move.l    a5,a1
  4458.         moveq    #0,d0
  4459.         CALL    OpenLibrary,sysbase(a4)
  4460.         tst.l    d0
  4461.         beq    fn5
  4462. opli1        rts
  4463.  
  4464. ;close it
  4465. closelib    bsr    nodenam2
  4466.         moveq    #0,d7
  4467.         lea    LibNode(pc),a3
  4468.         bsr    findnam
  4469.         tst.b    d7
  4470.         beq.s    clli1
  4471.         move.l    d0,a1
  4472.         CALL    CloseLibrary,sysbase(a4)
  4473. clli1        rts
  4474.  
  4475. remnode        bsr    nodenam2
  4476.         moveq    #7,d7
  4477.         lea    TReNode(pc),a3
  4478.         bsr    findnam
  4479.         tst.b    d7
  4480.         beq.s    1$
  4481.         move.l    d0,-(sp)
  4482.         CALL    Disable,sysbase(a4)
  4483.         move.l    (sp)+,a1
  4484.         RECALL    Remove
  4485.         RECALL    Enable
  4486. 1$        rts
  4487.  
  4488. remport        bsr    nodenam2
  4489.         moveq    #0,d7
  4490.         lea    PorNode(pc),a3
  4491.         bsr    findnam
  4492.         tst.b    d7
  4493.         beq.s    1$
  4494.         move.l    d0,a1
  4495.         move.l    16(a1),d0
  4496.         cmp.l    mytask(a4),d0        ; own port ?
  4497.         beq.s    1$
  4498.         move.b    #2,14(a1)
  4499.         CALL    RemPort,sysbase(a4)
  4500. 1$        rts
  4501.  
  4502. closetsports    movem.l    d1-d6/a0-a6,-(sp)
  4503.         move.l    d0,d6
  4504.         move.l    sysbase(a4),a3
  4505.         lea    392(a3),a3
  4506. 1$        move.l    0(a3),a3
  4507.         tst.l    0(a3)
  4508.         beq.s    2$
  4509.         cmp.l    16(a3),d6
  4510.         bne.s    1$
  4511.         move.b    #2,14(a3)
  4512.         move.l    a3,a1
  4513.         CALL    RemPort,sysbase(a4)
  4514.         bra.s    1$
  4515. 2$        movem.l    (sp)+,d1-d6/a0-a6
  4516.         rts
  4517.  
  4518. remintserver    move.l    a0,-(sp)
  4519.         bsr    readhex
  4520.         move.l    (sp)+,a0
  4521.         tst.b    d7
  4522.         beq    syntax
  4523.         move.l    d0,d4
  4524.         moveq    #1,d6
  4525.         move.l    a0,-(sp)
  4526.         bsr    findint
  4527.         move.l    (sp)+,a5
  4528.         tst.w    d5
  4529.         bpl.s    1$
  4530.         bra    fn5
  4531. 1$        tst.b    0(a3,d1.w)
  4532.         bne.s    2$
  4533.         move.w    #nintrserv,d0
  4534.         bra    putnamw
  4535. 2$        lea    iocounter(a4),a1
  4536.         cmp.l    a1,d4
  4537.         beq.s    3$            ; own server !
  4538.         move.l    d4,a1
  4539.         move.l    d1,d0
  4540.         CALL    RemIntServer,sysbase(a4)
  4541. 3$        rts
  4542.  
  4543. ;Remove a resident module from the list. Clears the rt_Matchword
  4544. ;to avoid being found and reinserted during the next reset
  4545.  
  4546. remresident    bsr    nodenam2
  4547.         cmp.b    #'$',0(a5)
  4548.         bne.s    1$
  4549.         move.l    a5,a0
  4550.         bsr    readhex
  4551.         move.l    sysbase(a4),a6
  4552.         tst.b    d7
  4553.         bne.s    2$
  4554. 1$        move.l    a5,a1
  4555.         RECALL    FindResident
  4556.         tst.l    d0
  4557.         beq    fn5
  4558.  
  4559. 2$        move.l    300(a6),a3        ; SysBase->ResModules
  4560. 8$        move.l    (a3)+,d1
  4561.         beq    fn5
  4562.         bpl.s    3$
  4563.         bclr    #31,d1
  4564.         movea.l    d1,a3
  4565.         bra.s    8$
  4566.  
  4567. 3$        cmp.l    d1,d0
  4568.         bne.s    8$
  4569.  
  4570. 4$        move.l    a3,a5
  4571. 5$        tst.l    (a5)+
  4572.         bgt.s    5$
  4573.  
  4574. 6$        move.l    d0,a1
  4575.         clr.w    0(a1)            ; rt_MatchTag
  4576.         clr.b    10(a1)            ; rt_Flags
  4577.         clr.l    22(a1)            ; rt_Init
  4578.         move.l    a5,d0
  4579.         sub.l    a3,d0
  4580.         lsr.w    #2,d0
  4581.         subq.w    #1,d0
  4582.         lea    -4(a3),a1
  4583. 7$        move.l    (a3)+,(a1)+
  4584.         dbra    d0,7$
  4585.         rts
  4586.  
  4587. ;end Xoper but stay in background
  4588. quithold    lea    dummy(a4),a0
  4589.         lea    in(a4),a1
  4590. qh1        move.b    (a0),(a1)+
  4591.         cmp.b    #10,(a0)+
  4592.         bne.s    qh1
  4593.  
  4594. instback    st    wanthold(a4)
  4595.         tst.b    fromfile(a4)
  4596.         bne.s    quithold-2        ; defer hold
  4597.         moveq    #0,d0
  4598.         bsr    CloseGUI        ; close screen & window
  4599.         beq.s    quithold-2        ; hack ! (pubscreen used)
  4600.         tst.b    wantwindow(a4)
  4601.         beq.s    6$
  4602.         clr.b    wantwindow(a4)
  4603.         clr.b    ownscreen(a4)
  4604.  
  4605. 6$        bsr    killpage
  4606.         bsr    freeblank
  4607.  
  4608.         tst.b    iconifyon(a4)
  4609.         beq.s    3$
  4610.  
  4611. ; appicon (d7=2) or a window (d7=0) !
  4612.  
  4613.         moveq    #2,d7
  4614.         move.l    wbbase(a4),d0        ; try appicon
  4615.         beq.s    5$
  4616.         move.l    a4,-(sp)
  4617.         move.l    d0,a6            ; library base
  4618.         moveq    #0,d0            ; id
  4619.         moveq    #0,d1            ; userdata
  4620.         lea    noname(a4),a0        ; name
  4621.         move.l    replyport(a4),a1    ; port
  4622.         suba.l    a2,a2            ; lock
  4623.         lea    appobj(a4),a3        ; diskobj
  4624.         suba.l    a4,a4            ; tagitems
  4625.         RECALL    AddAppIcon
  4626.         move.l    (sp)+,a4
  4627.         tst.l    d0
  4628.         bne.s    4$
  4629. 5$        moveq    #0,d7
  4630.         lea    icnwindow(a4),a0    ; try icon window
  4631.         CALL    OpenWindow,intuibase(a4)
  4632. 4$        move.l    d0,wnptr(a4)
  4633.         move.b    d7,appicn(a4)
  4634. 3$        bsr.s    handleiconify        ; do iconify
  4635.         move.l    wnptr(a4),d0
  4636.         beq.s    1$
  4637.         move.l    d0,a0
  4638.         moveq    #_LVORemoveAppIcon,d0
  4639.         tst.w    d7
  4640.         bne.s    2$
  4641.         moveq    #_LVOCloseWindow,d0
  4642. 2$        jsr    0(a6,d0.w)        ; remove iconify stuff
  4643.         clr.l    wnptr(a4)
  4644.         clr.b    appicn(a4)
  4645.  
  4646. 1$        clr.b    wanthold(a4)
  4647.         move.b    wantexit(a4),waitexit(a4)
  4648.         bne    exitall
  4649.         move.l    savesp(a4),sp
  4650.         bra    restart
  4651.  
  4652. ; wait for wakeup
  4653.  
  4654. handleiconify    move.l    a6,-(sp)
  4655.         move.l    sysbase(a4),a6        ; setup a6 to ExecBase
  4656.  
  4657.         move.l    mysignal(a4),d6        ; build signal mask
  4658.         or.l    trapmask(a4),d6
  4659.         move.w    cxsig(a4),d0
  4660.         beq.s    3$            ; no commodity
  4661.         bset    d0,d6
  4662. 3$        move.l    replyport(a4),a2
  4663.         tst.w    d7
  4664.         bne.s    2$            ; appicon
  4665.         move.l    wnptr(a4),d2
  4666.         beq.s    1$
  4667.         move.l    d2,a2
  4668.         move.l    86(a2),a2        ; wn->UserPort
  4669. 2$        move.b    15(a2),d0        ; Port->SigBit
  4670.         bset    d0,d6
  4671. 1$        or.w    #$1000,d6        ; crtl-c
  4672.  
  4673. waitforcall    move.l    d6,d0            ; complete wait-mask
  4674.         RECALL    Wait
  4675.         btst    #mysigbit,d0
  4676.         bne.s    icondone        ; hotkey !!
  4677.         btst    #12,d0
  4678.         sne    wantexit(a4)
  4679.         bne.s    icondone        ; ctrl-c
  4680.         move.l    trapmask(a4),d1
  4681.         and.l    d0,d1
  4682.         sne    gotguru(a4)
  4683.         bne.s    icondone        ; guru !!
  4684.         bsr    ChkBroker        ; check broker port
  4685.  
  4686. fromport    move.l    a2,a0            ; wn->UserPort
  4687.         RECALL    GetMsg
  4688.         move.l    d0,a1
  4689.         move.l    a1,d0
  4690.         beq.s    waitforcall
  4691.         move.l    30(a1),-(sp)
  4692.         RECALL    ReplyMsg
  4693.         tst.w    d7            ; app icon ?
  4694.         bne.s    1$
  4695.         move.l    a6,(sp)            ; only flag
  4696.         bsr.s    chkpos
  4697.         bne.s    1$
  4698.         lea    osecs(a4),a3
  4699.         lea    8(a3),a0        ; nsecs
  4700.         lea    12(a3),a1        ; nmics
  4701.         move.l    a6,-(sp)
  4702.         CALL    CurrentTime,intuibase(a4)
  4703.         movem.l    0(a3),d0-d3
  4704.         RECALL    DoubleClick
  4705.         move.l    (sp)+,a6
  4706.         move.l    8(a3),(a3)+        ; nsecs->osecs
  4707.         move.l    8(a3),(a3)+        ; nmics->omics
  4708.         tst.l    d0
  4709.         beq.s    1$
  4710.         clr.l    (sp)            ; clear value
  4711. 1$        move.l    (sp)+,d0
  4712.         bne.s    fromport
  4713.  
  4714. icondone    move.l    (sp)+,a6
  4715.         tst.w    d7            ; appicon or window ?
  4716.         bne.s    chkpos2
  4717.  
  4718. chkpos        move.l    wnptr(a4),d0        ; window moved ?
  4719.         beq.s    chkpos2
  4720.         move.l    d0,a0
  4721.         move.l    4(a0),d0        ; new pos
  4722.         move.l    icnwindow(a4),d1    ; old pos
  4723.         move.l    d0,icnwindow(a4)
  4724.         sub.l    d1,d0            ; zero == nothing changed !
  4725. chkpos2        rts
  4726.  
  4727. ;fill all unused memory-chunks with a longword
  4728. clear        moveq    #0,d0
  4729.         cmp.b    #10,0(a0)
  4730.         beq.s    clr5
  4731.         bsr    readhex
  4732.         tst.b    d7
  4733.         beq    syntax
  4734. clr5        move.l    sysbase(a4),a0
  4735.         clr.l    parmtxt(a4)
  4736.         lea     322(a0),a0
  4737.         move.w    #$4000,$dff09a
  4738. clr1        move.l    0(a0),a0
  4739.         tst.l    0(a0)
  4740.         beq.s    clr6
  4741.         move.l    16(a0),a1
  4742. clr2        tst.l    0(a1)
  4743.         beq.s    clr1
  4744.         addq.l    #1,parmtxt(a4)
  4745.         move.l    4(a1),d1
  4746.         subq.l    #8,d1
  4747.         ble.s    clr31
  4748.         lsr.l    #2,d1
  4749.         subq.l    #1,d1
  4750.         bmi.s    clr31
  4751.         lea     8(a1),a2
  4752. clr3        move.l    d0,(a2)+
  4753.         dbra    d1,clr3
  4754. clr31        move.l    0(a1),a1
  4755.         bra.s    clr2
  4756. clr6        move.w    #$C000,$dff09a
  4757.         move.l    parmtxt(a4),d0
  4758.         moveq    #0,d3
  4759.         bsr    longdec
  4760.         move.w    #clrtxt,d0
  4761.         bra    putnamw
  4762.  
  4763. ;change the number of maximum lines in the history buffer
  4764. historylines    bsr    getnum
  4765.         tst.b    d7
  4766.         beq    syntax
  4767.         move.w    d2,maxhlines(a4)
  4768.         move.w    hnum(a4),d0
  4769. 1$        cmp.w    maxhlines(a4),d0
  4770.         ble.s    2$
  4771.         bsr    remhistline
  4772.         subq.w    #1,d0
  4773.         bra.s    1$
  4774. 2$        move.l    history+8(a4),curhist(a4)
  4775.         move.w    d0,hnum(a4)
  4776.         rts
  4777.  
  4778. ;set the minimum number of characters a input line
  4779. ;must have to be added to the history buffer
  4780. historylength    bsr    getnum
  4781.         tst.b    d7
  4782.         beq    syntax
  4783.         tst.b    d2
  4784.         bne.s    1$
  4785.         addq.w    #1,d2
  4786. 1$        move.w    d2,minnumchars(a4)
  4787.         rts
  4788.  
  4789. ;display all lines in the history buffer
  4790. showhistory    lea    inputbuffer(a4),a3
  4791.         moveq    #1,d5
  4792.         move.l    history(a4),a5
  4793. 1$        tst.l    0(a5)
  4794.         beq.s    2$
  4795.         move.l    d5,d3
  4796.         bsr    bytedec
  4797.         moveq    #0,d0
  4798.         move.w    8(a5),d0
  4799.         clr.b    0(a3,d0.w)
  4800.         lea    10(a5),a0
  4801.         move.l    a3,a1
  4802.         CALL    CopyMem,sysbase(a4)
  4803.         move.l    a3,d0
  4804.         bsr    putnam
  4805.         move.l    0(a5),a5
  4806.         addq.l    #1,d5
  4807.         bra.s    1$
  4808. 2$        rts
  4809.  
  4810. ;set the maximum lines the output buffer may hold
  4811. outputlines    bsr    getnum
  4812.         tst.b    d7
  4813.         beq    syntax
  4814.         moveq    #100,d3
  4815.         tst.l    d2
  4816.         bmi.s    2$
  4817.         cmp.l    d3,d2
  4818.         bge.s    1$
  4819. 2$        move.l    d3,d2
  4820. 1$        move.l    d2,maxlines(a4)
  4821.         rts
  4822.  
  4823. ;find a named node
  4824. ;d7 = number of lists to search through
  4825. ;a3 = pointer to the first entry in the
  4826. ;     list-offset-table
  4827. ;a5 = pointer to name
  4828. ;returns:
  4829. ;d7 = TRUE(1) / FALSE (0)
  4830. ;d0 = node
  4831. findnam        tst.b    0(a5)
  4832.         bne.s    1$
  4833.         move.w    #nameerr,d0
  4834.         bsr    putnamw
  4835.         bra    fnerr
  4836. 1$        cmp.b    #'$',0(a5)
  4837.         bne.s    fn2
  4838.         move.l    d7,d2
  4839.         move.l    a5,a0
  4840.         bsr    readhex
  4841.         tst.b    d7
  4842.         beq.s    fn6
  4843.         move.l    d2,d7
  4844.         bsr.s    tstnode
  4845.         tst.w    d5
  4846.         bne.s    fn3
  4847.         bra    fn5
  4848. fn6        move.l    d2,d7
  4849. fn2        move.l    sysbase(a4),a0
  4850.         adda.l    0(a3),a0
  4851.         move.l    a5,a1
  4852. fn4        CALL    FindName,sysbase(a4)
  4853.         move.l    d0,a0
  4854.         move.l    a0,d0
  4855.         bne.s    fn1
  4856. fn41        addq.w    #4,a3
  4857.         dbra    d7,fn2
  4858. fn5        move.w    #namerr,d0
  4859.         bsr    putstrw
  4860.         move.l    a5,d0
  4861.         bsr    putnam
  4862. fnerr        moveq    #0,d7
  4863.         rts
  4864. fn1        move.w    procnum(a4),d2
  4865.         beq.s    fn3
  4866.         cmp.b    143(a0),d2
  4867.         bne.s    fn41
  4868. fn3        moveq    #1,d7
  4869.         rts
  4870.  
  4871. ;list-offset-table
  4872. TRuNode        dc.l    276
  4873. TReNode        dc.l    406
  4874. TWaNode        dc.l    420
  4875. DevNode        dc.l    350
  4876. LibNode        dc.l    378
  4877. ResNode        dc.l    336
  4878. MemNode        dc.l    322
  4879. PorNode        dc.l    392
  4880. SemNode        dc.l    532
  4881.  
  4882. ;Node has been entered in hex. Check if this node exsists
  4883. tstnode        tst.b    fromfile(a4)
  4884.         bne.s    illegalhex
  4885.         move.l    d0,d1
  4886.         btst    #0,d1
  4887.         beq.s    inrange
  4888.         move.w    #adrerr,d0
  4889.         bsr    putnamw
  4890. illegalhex    moveq    #0,d5
  4891.         rts
  4892. inrange        movem.l    d7/a3,-(sp)
  4893.         moveq    #1,d5
  4894.         lea    TRuNode(pc),a0
  4895.         cmp.l    a0,a3
  4896.         bne.s    1$
  4897.         move.l    sysbase(a4),a0
  4898.         cmp.l    276(a0),d0
  4899.         beq.s    nodefound
  4900.         subq.w    #1,d7
  4901.         addq.w    #4,a3
  4902. 1$        move.w    #$4000,$dff09a
  4903. getlist        move.l    sysbase(a4),a0
  4904.         add.l    0(a3),a0
  4905. nxtnode        tst.l    0(a0)
  4906.         beq.s    nxtlist
  4907.         cmp.l    a0,d0
  4908.         beq.s    nodefound
  4909.         move.l    0(a0),a0
  4910.         bra.s    nxtnode
  4911. nxtlist        addq.w    #4,a3
  4912.         dbra    d7,getlist
  4913.         moveq    #0,d5
  4914. nodefound    move.w    #$C000,$dff09a
  4915.         movem.l    (sp)+,d7/a3
  4916.         rts
  4917.  
  4918. ;allocate FileInfoBlock
  4919. allocfinfo    addq.b    #1,finfopen(a4)
  4920.         bne.s    1$
  4921.         moveq    #(264>>3),d0
  4922.         lsl.w    #3,d0
  4923.         moveq    #0,d1
  4924.         CALL    AllocMem,sysbase(a4)
  4925.         move.l    d0,finfoptr(a4)
  4926. 1$        rts
  4927.  
  4928. ;free FileInfoBlock
  4929. freefinfo    subq.b    #1,finfopen(a4)
  4930.         bpl.s    1$
  4931.         move.l    finfoptr(a4),d0
  4932.         beq.s    1$
  4933.         move.l    d0,a1
  4934.         moveq    #(264>>3),d0
  4935.         lsl.w    #3,d0
  4936.         CALL    FreeMem,sysbase(a4)
  4937.         clr.l    finfoptr(a4)
  4938. 1$        rts
  4939.  
  4940. ;Examine ,d0=Lock
  4941. getfinfo    move.l    d0,d1
  4942.         move.l    finfoptr(a4),d2
  4943.         CALL    Examine,dosbase(a4)
  4944.         rts
  4945.  
  4946. ;construct a Pathname from a lock
  4947. ;d0=Lock ,resulting string is written to window
  4948. getpath        movem.l    d1-d7/a0-a6,-(sp)
  4949.         move.l    d0,d1
  4950.         beq.s    1$
  4951.         CALL    DupLock,dosbase(a4)
  4952. 1$        lea    out(a4),a3
  4953.         clr.b    -(a3)
  4954. gp0        move.l    d0,d5
  4955.         bsr.s    getfinfo
  4956.         move.l    finfoptr(a4),a0
  4957.         move.l    4(a0),d4
  4958.         addq.l    #8,a0
  4959.         bsr    strlen
  4960.         lea    -1(a3),a5
  4961.         tst.l    d4
  4962.         bmi.s    nodir
  4963.         move.b    #'/',-(a3)
  4964. nodir        subq.w    #1,d0
  4965.         bmi.s    nofnam
  4966. gp1        move.b    0(a0,d0.w),-(a3)
  4967.         dbra    d0,gp1
  4968. nofnam        move.l    d5,d1
  4969.         CALL    ParentDir,dosbase(a4)
  4970.         move.l    d0,d4
  4971.         move.l    d5,d1
  4972.         beq.s    2$
  4973.         CALL    UnLock,dosbase(a4)
  4974. 2$        move.l    d4,d0
  4975.         bne.s    gp0
  4976.         cmp.b    #'/',0(a5)
  4977.         bne.s    gp2
  4978.         move.b    #':',0(a5)
  4979. gp2        move.l    a3,d0
  4980.         bsr    putnam
  4981.         movem.l    (sp)+,d1-d7/a0-a6
  4982.         rts
  4983.  
  4984. dchange        lea    dchead(a4),a0
  4985.         bsr    puthead
  4986.         tst.b    post_V34(a4)
  4987.         bne.s    dchange-2        ; hack!
  4988.         move.l    sysbase(a4),a6
  4989.         lea    350(a6),a0
  4990.         lea    tdname(a4),a1
  4991.         RECALL    FindName
  4992.         move.l    d0,a2
  4993.         move.l    a2,d0
  4994.         beq    14$
  4995.         lea    36(a2),a2
  4996.         moveq    #0,d5
  4997. 2$        move.l    (a2)+,d2
  4998.         beq    3$
  4999.         RECALL    Disable
  5000.         move.l    d2,a0
  5001.         lea    $18e(a0),a0
  5002. 5$        tst.l    0(a0)
  5003.         beq.s    6$
  5004.         move.l    0(a0),a0
  5005.         bra.s    5$
  5006. 6$        lea    -4(a0),a5
  5007.         lea    buffer+100(a4),a3
  5008. 9$        move.l    0(a5),a5
  5009.         tst.l    0(a5)
  5010.         beq.s    11$
  5011.         move.l    a5,(a3)+
  5012.         bne.s    9$
  5013. 11$        clr.l    (a3)+
  5014.         RECALL    Enable
  5015.         lea    buffer+100(a4),a3
  5016. 7$        move.l    (a3)+,d0
  5017.         beq.s    3$
  5018.         move.l    d0,a5
  5019.         cmp.w    #20,28(a5)
  5020.         bne.s    7$
  5021.         move.l    40(a5),a3
  5022.         move.l    a3,d0
  5023.         move.l    d0,node(a4)
  5024.         bsr    hexan
  5025.         move.l    a3,d0
  5026.         beq.s    10$
  5027.         move.l    14(a3),d0
  5028.         bsr    hexan
  5029.         move.l    18(a3),d0
  5030.         bsr    hexan
  5031. 10$        move.l    d5,d3
  5032.         or.b    #48,d3
  5033.         move.b    d3,tddrives+2(a4)
  5034.         move.w    #tddrives,d0
  5035.         bsr    putstrw
  5036.         move.l    14(a5),d0
  5037.         beq.s    8$
  5038.         move.l    d0,a0
  5039.         move.l    16(a0),d0
  5040. 8$        bsr    getaskname2
  5041.         bsr    newline
  5042.         bra.s    7$
  5043. 3$        addq.w    #1,d5
  5044.         cmp.w    #4,d5
  5045.         bcs    2$
  5046. 14$        rts
  5047.  
  5048. snoop        lea    snoophead(a4),a2
  5049.         moveq    #0,d2
  5050.         bsr    InitSnoop
  5051.         beq.s    snoop-2
  5052.  
  5053.         tst.b    msnoop(a4)
  5054.         bne.s    1$            ; already patched !
  5055.         RECALL    Forbid
  5056.         lea    capmalloc(pc),a0
  5057.         move.l    a0,d0
  5058.         move.w    #_LVOAllocMem,a0
  5059.         move.l    a6,a1
  5060.         RECALL    SetFunction
  5061.         move.l    d0,OldAllocMem(a4)
  5062.         lea    capmfree(pc),a0
  5063.         move.l    a0,d0
  5064.         move.w    #_LVOFreeMem,a0
  5065.         move.l    a6,a1
  5066.         RECALL    SetFunction
  5067.         move.l    d0,OldFreeMem(a4)
  5068.         st    msnoop(a4)
  5069.         RECALL    Permit
  5070.  
  5071. 1$        st    snoopon(a4)        ; enable snooping
  5072.         clr.b    bool(a4)
  5073.         clr.b    capgone(a4)
  5074.         clr.b    capwaiting(a4)
  5075.         clr.l    capiscli(a4)
  5076.  
  5077.         move.l    captask(a4),a1
  5078.         cmp.b    #13,8(a1)        ; ln_Type
  5079.         bne.s    waitmem
  5080.         tst.l    140(a1)
  5081.         beq.s    waitmem
  5082.         move.l    172(a1),d0        ; pr_CLI
  5083.         beq.s    waitmem
  5084.         lsl.l    #2,d0
  5085.         move.l    d0,a0
  5086.         lea     60(a0),a0
  5087.         move.l    a0,capiscli(a4)
  5088.         move.l    0(a0),d0
  5089.         move.l    d0,capseg(a4)
  5090.         bne.s    waitmem
  5091.         move.w    #capwait,d0
  5092.         bsr    putnamw
  5093.         st    capwaiting(a4)
  5094.  
  5095. waitmem        bsr    processmsgs
  5096.  
  5097. tm7        move.l    snoopport(a4),a0
  5098.         CALL    GetMsg,sysbase(a4)
  5099.         move.l    d0,a3
  5100.         move.l    a3,d0
  5101.         bne.s    tm8
  5102.         tst.b    cbreak(a4)
  5103.         bne    snoopend
  5104.         tst.b    capgone(a4)
  5105.         bne    snoopend
  5106.         bra.s    waitmem
  5107.  
  5108. tm8        tst.b    capwaiting(a4)
  5109.         beq.s    tm15
  5110.         move.l    capiscli(a4),d7
  5111.         beq.s    tm15
  5112.         move.l    d7,a0
  5113.         move.l    0(a0),capseg(a4)
  5114.         beq    tm12
  5115.         clr.b    capwaiting(a4)
  5116.  
  5117. tm15        move.l    20(a3),d3
  5118.         tst.b    36(a3)            ; free or alloc ?
  5119.  
  5120.         beq    freed
  5121.         move.w    #allok,d0
  5122.         bsr    putstrw
  5123.         lea    memname(pc),a2
  5124.         moveq    #9,d5
  5125. tm2        move.w    (a2)+,d1
  5126.         btst    d1,d3
  5127.         beq.s    tm1
  5128.         move.w    (a2),d0
  5129.         bsr    putstrw
  5130. tm1        addq.w    #2,a2
  5131.         dbra    d5,tm2
  5132.         moveq    #41,d1
  5133.         bsr    tab            ; d0 - actual pos
  5134.         bsr    putblank
  5135.         move.l    24(a3),d0
  5136.         move.l    d0,d3
  5137.         bsr    hexa
  5138.         move.l    28(a3),d0
  5139.         bne.s    tm3
  5140.         move.w    #failed,d0
  5141.         bsr    putstrw
  5142.         moveq    #53,d1
  5143.         bsr    tab
  5144.         bra.s    tm4
  5145. tm3        bsr    hexa
  5146.         move.l    28(a3),d0
  5147.         add.l    d3,d0
  5148.         bsr    hexa
  5149.         bra.s    tm4
  5150.  
  5151. freed        move.w    #free,d0
  5152.         bsr    putstrw
  5153.         move.b    #'-',d0
  5154.         moveq    #34,d1
  5155. tm9        bsr    putchar
  5156.         dbra    d1,tm9
  5157.         bsr    putblank
  5158.         move.l    d3,d0
  5159.         bsr    hexa
  5160.         move.l    24(a3),d0
  5161.         bsr    hexa
  5162.         move.l    24(a3),d0
  5163.         add.l    d3,d0
  5164.         bsr    hexa
  5165.  
  5166. tm4        move.l    32(a3),d0
  5167.         bsr    hexa
  5168.         bsr    newline
  5169. tm12        bsr    freemsg
  5170.         move.l    captask(a4),a1
  5171. tm13        tst.b    capwaiting(a4)
  5172.         bne.s    tm10
  5173.         move.l    capiscli(a4),d0
  5174.         beq.s    1$
  5175.         move.l    d0,a0
  5176.         move.l    0(a0),d0
  5177.         cmp.l    capseg(a4),d0
  5178.         bne.s    tm11
  5179. 1$        move.b    15(a1),d0
  5180.         cmp.b    #5,d0
  5181.         bge.s    tm11
  5182.         cmp.b    #2,d0
  5183.         bge.s    tm10
  5184. tm11        st    capgone(a4)
  5185. tm10        bra    tm7
  5186.  
  5187. snoopend    clr.b    snoopon(a4)        ; snooping off
  5188.         tst.b    msnoop(a4)
  5189.         beq.s    1$            ; nothing patched !
  5190.         CALL    Forbid,sysbase(a4)
  5191.         tst.b    patchmode(a4)
  5192.         beq.s    3$            ; don't check vectors
  5193.         lea    capmalloc(pc),a0
  5194.         cmp.l    _LVOAllocMem+2(a6),a0
  5195.         bne.s    2$            ; another patch !
  5196.         lea    capmfree(pc),a0
  5197.         cmp.l    _LVOFreeMem+2(a6),a0
  5198.         bne.s    2$            ; another patch !
  5199. 3$        move.l    OldFreeMem(a4),d0
  5200.         move.w    #_LVOFreeMem,a0
  5201.         move.l    a6,a1
  5202.         RECALL    SetFunction
  5203.         move.l    OldAllocMem(a4),d0
  5204.         move.w    #_LVOAllocMem,a0
  5205.         move.l    a6,a1
  5206.         RECALL    SetFunction
  5207.         clr.b    msnoop(a4)
  5208. 2$        RECALL    Permit
  5209. 1$        bra    ClrSnoop
  5210.  
  5211. memname        dc.w    31,memnoexp,18,memrev,17,memlarg,16,memclr,10,memkick
  5212.         dc.w    9,memdma,8,memloc,2,memfast,1,memchip,0,mempubl
  5213.  
  5214. capmalloc    movem.l    d0-d7/a0-a6,-(sp)    ; a6 - SysBase !
  5215.         lea    dataarea(pc),a4
  5216.         tst.b    snoopon(a4)
  5217.         beq.s    capm1            ; snooping disabled
  5218.         move.l    276(a6),d4
  5219.         cmp.l    captask(a4),d4
  5220.         bne.s    capm1
  5221.         tst.b    bool(a4)
  5222.         bne.s    capm1
  5223.         addq.b    #1,bool(a4)
  5224.         moveq    #40,d6
  5225.         bsr    allocmsg
  5226.         beq.s    capm2
  5227.         move.l    d1,20(a5)
  5228.         move.l    d0,24(a5)
  5229.         move.l    60(sp),32(a5)
  5230.         st    36(a5)            ; is alloc msg
  5231.         move.l    a5,remembr(a4)
  5232.         movem.l    (sp)+,d0-d7/a0-a6
  5233.         bsr.s    memalloc
  5234.         movem.l    d0-d7/a0-a6,-(sp)
  5235.         lea    dataarea(pc),a4
  5236.         move.l    remembr(a4),a1
  5237.         move.l    d0,28(a1)
  5238.         move.l    snoopport(a4),a0
  5239.         move.b    #5,8(a1)
  5240.         RECALL    PutMsg
  5241.         clr.b    bool(a4)
  5242.         movem.l    (sp)+,d0-d7/a0-a6
  5243.         rts
  5244. capm2        clr.b    bool(a4)
  5245. capm1        movem.l    (sp)+,d0-d7/a0-a6
  5246. memalloc    move.l    OldAllocMem+dataarea(pc),-(sp)
  5247.         rts
  5248.  
  5249. capmfree    movem.l    d0-d7/a0-a6,-(sp)    ; a6 - SysBase !
  5250.         lea    dataarea(pc),a4
  5251.         tst.b    snoopon(a4)
  5252.         beq.s    capf1            ; snooping disabled
  5253.         move.l    276(a6),d4
  5254.         cmp.l    captask(a4),d4
  5255.         bne.s    capf1
  5256.         tst.b    bool(a4)
  5257.         bne.s    capf1
  5258.         addq.b    #1,bool(a4)
  5259.         moveq    #40,d6
  5260.         bsr.s    allocmsg
  5261.         beq.s    capf2
  5262.         move.l    d0,20(a5)
  5263.         move.l    a1,24(a5)
  5264.         move.l    60(sp),32(a5)
  5265. ;        clr.b    36(a5)            ; is free msg
  5266.         move.l    snoopport(a4),a0
  5267.         move.b    #5,8(a5)
  5268.         move.l    a5,a1
  5269.         RECALL    PutMsg
  5270. capf2        clr.b    bool(a4)
  5271. capf1        movem.l (sp)+,d0-d7/a0-a6
  5272.         move.l  OldFreeMem+dataarea(pc),-(sp)
  5273.         rts
  5274.  
  5275. allocmsg    movem.l    d0-d1/a0-a1,-(sp)    ; a6 - SysBase
  5276.         move.l    d6,d0
  5277.         move.l    pubclr(a4),d1        ; MEMF_CLEAR|MEMF_PUBLIC
  5278.         tst.b    msnoop(a4)        ; memory snooping ?
  5279.         bne.s    1$
  5280.         RECALL    AllocMem
  5281.         bra.s    2$
  5282. 1$        bsr.s    memalloc
  5283. 2$        tst.l    d0
  5284.         beq.s    alm1
  5285.         move.l    d0,a5
  5286.         move.w    d6,18(a5)
  5287. alm1        movem.l    (sp)+,d0-d1/a0-a1
  5288.         rts
  5289.  
  5290. freemsg        moveq    #0,d0
  5291.         move.w    18(a3),d0
  5292.         move.l    a3,a1
  5293.         CALL    FreeMem,sysbase(a4)
  5294.         rts
  5295.  
  5296. tracelocks    pea    DosTable+20(a4)        ; table entry for locks
  5297.         bra.s    tracedos
  5298.  
  5299. tracefiles    pea    DosTable+00(a4)        ; table entry for open
  5300.  
  5301. tracedos    lea    fileshead(a4),a2
  5302.         moveq    #1,d2
  5303.         bsr    InitSnoop
  5304.         move.l    (sp)+,a2
  5305.         beq.s    tracelocks-2        ; error
  5306.  
  5307.         RECALL    Forbid
  5308.         tst.b    5(a2)
  5309.         bne.s    9$            ; already patched !
  5310.         move.w    0(a2),a0        ; offset
  5311.         move.l    16(a2),d0        ; myfunc
  5312.         move.l    dosbase(a4),a1
  5313.         tst.b    post_V34(a4)
  5314.         beq.s    10$
  5315.         RECALL    SetFunction
  5316.         move.l    d0,12(a2)        ; OldFuncPtr
  5317.         bra.s    9$
  5318. 10$        move.w    0(a1,a0.w),6(a2)    ; OldVec1
  5319.         move.w    #$4ef9,0(a1,a0.w)
  5320.         move.l    2(a1,a0.w),8(a2)    ; OldVec2
  5321.         move.l    d0,2(a1,a0.w)
  5322.         lea    78(a1),a1
  5323.         move.l    a1,12(a2)        ; OldFuncPtr
  5324. 9$        moveq    #-1,d0
  5325.         move.w    d0,4(a2)        ; function patched & active
  5326.         RECALL    Permit
  5327.  
  5328. 8$        bsr    processmsgs
  5329.  
  5330. 7$        move.l    snoopport(a4),a0
  5331.         CALL    GetMsg,sysbase(a4)
  5332.         tst.l    d0
  5333.         bne.s    6$
  5334.         tst.b    cbreak(a4)
  5335.         bne.s    traceend
  5336.         bra.s    8$
  5337.  
  5338. 6$        move.l    d0,a3
  5339.         move.l    20(a3),d0
  5340.         bsr    getaskname2
  5341.         moveq    #11,d1
  5342.         bsr    tab
  5343.         moveq    #' ',d0
  5344.         bsr    putchar
  5345.         move.l    24(a3),d0
  5346.         bne.s    5$
  5347.         move.w    #failed,d0
  5348.         bsr    putstrw
  5349.         moveq    #21,d1
  5350.         bsr    tab
  5351.         bra.s    4$
  5352.  
  5353. 5$        bsr    hexa
  5354. 4$        move.b    28(a3),d0
  5355.         bmi.s    3$
  5356.         cmp.b    #2,d0
  5357.         ble.s    2$
  5358. 3$        move.w    #type,d0
  5359.         bsr    putstrw
  5360.         moveq    #28,d1
  5361.         bsr    tab
  5362.         bra.s    1$
  5363. 2$        ext.w    d0
  5364.         lsl.w    #3,d0
  5365.         add.w    #fmode,d0
  5366.         bsr    putstrw
  5367. 1$        moveq    #29,d0
  5368.         add.l    a3,d0
  5369.         bsr    putnam
  5370.  
  5371.         bsr    freemsg
  5372.         bra.s    7$
  5373.  
  5374. traceend    lea    DosTable+00(a4),a2
  5375.         bsr.s    remtrace        ; for Open()
  5376.         lea    DosTable+20(a4),a2
  5377.         bsr.s    remtrace        ; for Lock()
  5378.         bra    ClrSnoop
  5379.  
  5380. remtrace    CALL    Forbid,sysbase(a4)
  5381.         tst.b    5(a2)
  5382.         beq.s    2$            ; nothing patched !
  5383.         move.w    0(a2),a0        ; offset
  5384.         move.l    16(a2),d0        ; myfunc
  5385.         move.l    dosbase(a4),a1
  5386.         move.b    post_V34(a4),d1
  5387.         beq.s    6$            ; not pre Kick2.0+ !
  5388.         tst.b    patchmode(a4)
  5389.         beq.s    5$            ; don't check vectors
  5390. 6$        cmp.l    2(a1,a0.w),d0
  5391.         bne.s    2$            ; someone else patched !
  5392.         tst.b    d1            ; d1:=post_V34
  5393.         beq.s    4$
  5394. 5$        move.l    12(a2),d0
  5395.         RECALL    SetFunction
  5396.         bra.s    3$
  5397. 4$        move.w    6(a2),0(a1,a0.w)
  5398.         move.l    8(a2),2(a1,a0.w)
  5399. 3$        clr.b    5(a2)
  5400. 2$        clr.b    4(a2)            ; deactivate
  5401.         RECALL    Permit
  5402.         rts
  5403.  
  5404. mylock        moveq    #20,d0            ; trace Lock()
  5405.         bra.s    mytrace
  5406.  
  5407. myopen        moveq    #0,d0            ; trace Open()
  5408.  
  5409. mytrace        movem.l    d3-d7/a0-a6,-(sp)
  5410.         lea    dataarea(pc),a4
  5411.         lea    DosTable(a4),a2
  5412.         add.w    d0,a2
  5413.         move.b    4(a2),d7
  5414.         beq.s    5$            ; disabled
  5415.         move.l    sysbase(a4),a6
  5416.         movem.l    d1-d2,-(sp)
  5417.         move.l    d1,a0
  5418.         bsr    strlen
  5419.         moveq    #30,d6
  5420.         add.l    d0,d6
  5421.         bsr    allocmsg
  5422.         beq.s    2$
  5423.         addq.w    #3,d2            ; lock
  5424.         move.w    2(a2),d3        ; dosoffset
  5425.         addq.w    #1,d3
  5426.         bne.s    3$
  5427.         sub.w     #1007,d2        ; open
  5428. 3$        move.b    d2,28(a5)
  5429.         move.l    276(a6),20(a5)
  5430.         lea    29(a5),a1
  5431.         move.l    d1,a0
  5432.         RECALL    CopyMem
  5433. 2$        movem.l    (sp)+,d1-d2
  5434. 5$        bsr.s    RealDosFunc
  5435.         tst.b    d7            ; disabled
  5436.         beq.s    6$
  5437.         movem.l    d1-d2,-(sp)
  5438.         move.l    d0,d7
  5439.         move.l    a5,d0
  5440.         beq.s    1$
  5441.         move.b    #5,8(a5)
  5442.         move.l    d7,24(a5)
  5443.         move.l    snoopport(a4),a0
  5444.         move.l    a5,a1
  5445.         CALL    PutMsg,sysbase(a4)
  5446. 1$        move.l    d7,d0
  5447.         movem.l    (sp)+,d1-d2
  5448. 6$        movem.l    (sp)+,d3-d7/a0-a6
  5449.         rts
  5450.  
  5451. RealDosFunc    move.w    2(a2),d0        ; dosoffset
  5452.         ext.l    d0
  5453.         move.l    dosbase(a4),a6
  5454.         move.l    12(a2),-(sp)        ; OldFuncPtr
  5455.         rts
  5456.  
  5457. _DosTable    dc.w    _LVOOpen,-1        ; patchwhat & dosoffset
  5458.         dc.w    0,0            ; active,on/off & DosVec1
  5459.         dc.l    0,0            ; DosVec2 & OldFunc
  5460.         dc.l    myopen            ; myfunc
  5461.         dc.w    _LVOLock,-11        ; patchwhat & dosoffset
  5462.         dc.w    0,0            ; active,on/off & DosVec1
  5463.         dc.l    0,0            ; DosVec2 & OldFunc
  5464.         dc.l    mylock            ; myfunc
  5465.  
  5466. ;prepare snooping for memory or dos
  5467. InitSnoop    bsr    cls            ; clear screen
  5468.         tst.w    d2
  5469.         bne.s    2$            ; files
  5470.         bsr    nodenam
  5471.         moveq    #1,d7
  5472.         lea    TReNode(pc),a3
  5473.         bsr    findnam
  5474.         tst.b    d7
  5475.         beq.s    3$            ; task not found
  5476.         move.l    d0,captask(a4)
  5477. 2$        moveq    #0,d0
  5478.         lea    memportname(a4),a0
  5479.         bsr    CreatePort
  5480.         move.l    d0,snoopport(a4)
  5481.         beq.s    1$            ; no port
  5482.         move.l    d0,a0
  5483.         moveq    #0,d1
  5484.         move.b    15(a0),d0
  5485.         bset    d0,d1
  5486.         move.l    d1,auxsig(a4)
  5487.         clr.b    cbreak(a4)
  5488.         st    addlines(a4)
  5489.         move.l    a2,a0            ; header
  5490.         bsr    puthead
  5491.         bsr    replyintui
  5492.         move.l    sysbase(a4),a6
  5493.         moveq    #1,d0
  5494. 1$        rts
  5495. 3$        move.w    #stperr,d0
  5496.         bsr    putnamw            ; task not found
  5497.         moveq    #0,d0
  5498.         bra.s    1$
  5499.  
  5500. ;end snooping for memory or dos
  5501. ClrSnoop    move.l    snoopport(a4),d0
  5502.         beq.s    3$
  5503.         bsr    DeletePort
  5504. 3$        tst.b    waitexit(a4)
  5505.         bne.s    1$            ; Xoper was killed
  5506.         move.w    #stopped,d0
  5507.         tst.b    cbreak(a4)
  5508.         bne.s    2$
  5509.         move.w    #capexited,d0
  5510. 2$        bsr    putnamw
  5511. 1$        clr.l    snoopport(a4)
  5512.         clr.b    addlines(a4)
  5513.         clr.l    auxsig(a4)
  5514.         rts
  5515.  
  5516. ; function to determine cpu-time for each task
  5517. myswitch    movem.l    d0-d1/a0-a2/a4/a6,-(sp)
  5518.         lea    dataarea(pc),a4
  5519.         move.w    tasksnum(a4),d0
  5520.         move.l    sysbase(a4),a0
  5521.         move.l    276(a0),a0
  5522.         lea    cputime(a4),a2
  5523.         bra.s    sw1
  5524. sw0        cmp.l    (a2)+,a0
  5525.         beq.s    sw2
  5526. sw1        dbra    d0,sw0
  5527.         cmp.w    #125,tasksnum(a4)
  5528.         bcc.s    swgo2            ; too much
  5529.         addq.w    #1,tasksnum(a4)
  5530.         move.l    a0,(a2)+        ; new entry
  5531.         clr.l    496(a2)
  5532. sw2        tst.b    post_V34(a4)
  5533.         beq.s    sw3
  5534.         lea    newtime(a4),a0
  5535.         CALL    ReadEClock,timerio+20(a4)
  5536.         move.l    newtime+4(a4),d0
  5537.         move.l    lasttime(a4),d1
  5538.         move.l    d0,lasttime(a4)
  5539.         sub.l    d1,d0
  5540.         bra.s    sw4
  5541. sw3        move.l    #999999,d0
  5542.         move.l    d0,d1
  5543.         sub.l    sampleio+36(a4),d0
  5544.         move.l    d1,sampleio+36(a4)
  5545. sw4        lsr.l    #8,d0
  5546.         add.l    d0,496(a2)
  5547. swgo2        movem.l    (sp)+,d0-d1/a0-a2/a4/a6
  5548.         move.l    OldSwitch+dataarea(pc),-(sp)
  5549.         rts
  5550.  
  5551. myaddtask    movem.l    d0/a0/a4,-(sp)
  5552.         lea    dataarea(pc),a4
  5553.         tst.b    wanttraps(a4)
  5554.         beq.s    2$
  5555.         lea    mytrap(pc),a0        ; trap for task
  5556.         move.l    50(a1),d0
  5557.         beq.s    1$
  5558.         cmp.l    OldTrap(a4),d0
  5559.         beq.s    1$
  5560.         lea    myproctrap(pc),a0    ; trap for process
  5561.         cmp.l    OldProcTrap(a4),d0
  5562.         bne.s    2$
  5563. 1$        move.l    a0,50(a1)
  5564. 2$        movem.l    (sp)+,d0/a0/a4
  5565.         move.l    a1,-(sp)
  5566.         bsr.s    RealAddTask        ; do original function
  5567.         move.l    (sp)+,d0
  5568.         movem.l    d1-d7/a0-a6,-(sp)
  5569.         lea    dataarea(pc),a4
  5570.         move.l    d0,d7
  5571.         lea    tsecs(a4),a0
  5572.         lea    tmics(a4),a1
  5573.         CALL    CurrentTime,intuibase(a4)
  5574.         CALL    Forbid,sysbase(a4)
  5575.         move.w    numtaskstimed(a4),d5
  5576.         lsl.w    #2,d5
  5577.         lea    taskstampid(a4),a5
  5578.         lea    0(a5,d5.w),a5
  5579.         move.l    d7,0(a5)
  5580.         move.l    tsecs(a4),d0
  5581.         move.l    d0,taskstamps-taskstampid(a5)
  5582.         clr.l    usedtime-taskstampid(a5)
  5583.         addq.w    #1,numtaskstimed(a4)
  5584.         bsr    cleanuptimers
  5585.         RECALL    Permit
  5586.         cmp.b    #5,timerio+8(a4)
  5587.         bne.s    3$
  5588.         moveq    #0,d0
  5589.         move.w    timersig(a4),d1
  5590.         bset    d1,d0
  5591.         move.l    mytask(a4),a1
  5592.         RECALL    Signal
  5593. 3$        move.l    d7,d0
  5594.         movem.l    (sp)+,d1-d7/a0-a6
  5595.         rts
  5596. RealAddTask    move.l    OldAddTask+dataarea(pc),-(sp)
  5597.         rts
  5598.  
  5599. ; install or remove traphandlers
  5600.  
  5601. trapguru    tst.b    fromfile(a4)
  5602.         bne.s    1$            ; not during startup ...
  5603.         tst.b    wanttraps(a4)
  5604.         bne.s    remtraps
  5605.         moveq    #-1,d0            ; addtraps
  5606.         CALL    AllocSignal,sysbase(a4)
  5607.         move.b    d0,trapsig+3(a4)
  5608.         blt.s    1$
  5609.         moveq    #0,d1
  5610.         bset    d0,d1
  5611.         move.l    d1,trapmask(a4)
  5612.         RECALL    Forbid            ; change the trap handler of
  5613.         moveq    #0,d5            ; aleady running tasks
  5614.         bsr    getaskdat        ; get task stucture pointers
  5615.         bra.s    2$
  5616. 4$        lea    -16(a5),a5
  5617.         move.l    0(a5),a3        ; pointer to a task structure
  5618.         lea    myproctrap(pc),a0
  5619.         move.l    50(a3),d0        ; Task->tc_TrapCode
  5620.         cmp.l    OldProcTrap(a4),d0    ; AmigaDOS Handler ?
  5621.         beq.s    3$
  5622.         lea    mytrap(pc),a0        ; EXEC Handler ?
  5623.         cmp.l    OldTrap(a4),d0
  5624.         bne.s    2$            ; must be a custom one, skip it
  5625. 3$        move.l    a0,50(a3)        ; replace it
  5626. 2$        subq.b    #1,entries(a4)
  5627.         bcc.s    4$
  5628.         RECALL    Permit
  5629.         st    wanttraps(a4)
  5630. 1$        rts
  5631.  
  5632. remtraps    tst.b    wanttraps(a4)
  5633.         beq.s    1$
  5634.         CALL    Forbid,sysbase(a4)
  5635.         moveq    #0,d5
  5636.         bsr    getaskdat
  5637.         bra.s    2$
  5638. 4$        lea    -16(a5),a5
  5639.         move.l    0(a5),a3
  5640.         lea    50(a3),a3
  5641.         move.l    OldProcTrap(a4),d0
  5642.         lea    myproctrap(pc),a0
  5643.         cmp.l    (a3),a0
  5644.         beq.s    3$
  5645.         move.l    OldTrap(a4),d0
  5646.         lea    mytrap(pc),a0
  5647.         cmp.l    (a3),a0
  5648.         bne.s    2$
  5649. 3$        move.l    d0,(a3)
  5650. 2$        subq.b    #1,entries(a4)
  5651.         bcc.s    4$
  5652.         RECALL    Permit
  5653.         move.l    trapsig(a4),d0
  5654.         RECALL    FreeSignal
  5655.         clr.l    trapsig(a4)
  5656.         clr.b    wanttraps(a4)
  5657. 1$        rts
  5658.  
  5659. ; execption handlers
  5660.  
  5661. myproctrap    bsr.s    traphandle
  5662.         move.l    OldProcTrap+dataarea(pc),-(sp)
  5663.         rts
  5664.  
  5665. mytrap        bsr.s    traphandle
  5666.         moveq    #0,d0
  5667.         CALL    Wait,sysbase+dataarea(pc)
  5668.         move.l    OldTrap+dataarea(pc),-(sp)
  5669.         rts
  5670.  
  5671. traphandle    movem.l    d0-d7/a0-a6,$180
  5672.         lea    dataarea(pc),a4
  5673.         move.l    sysbase(a4),a6
  5674.         move.l    276(a6),excpttask(a4)
  5675.         move.l    4(sp),d0
  5676.         moveq    #9,d1
  5677.         cmp.l    d1,d0
  5678.         beq.s    2$
  5679.         move.l    d0,excpterror(a4)
  5680.         moveq    #10,d2
  5681.         moveq    #3,d1
  5682.         cmp.l    d1,d0
  5683.         bne.s    1$
  5684.         move.l    0(sp,d2.w),excptaddr(a4)
  5685.         moveq    #18,d2
  5686. 1$        move.l    0(sp,d2.w),excptpc(a4)
  5687.         move.l    mytask(a4),a1
  5688.         move.l    trapmask(a4),d0
  5689.         RECALL    Signal
  5690. 2$        movem.l    $180,d0-d7/a0-a6
  5691.         rts
  5692.  
  5693. ;display ExecBase->LastAlert
  5694.  
  5695. lastalert    movem.l    $100,d1-d2
  5696.         tst.l    d1
  5697.         bne.s    al1
  5698.         move.l    sysbase(a4),a0
  5699.         movem.l    514(a0),d1-d2
  5700. al1        move.w    #gurutxt,d0
  5701.         bsr    putstrw
  5702.         move.l    d1,d0
  5703.         bsr    hexa
  5704.         subq.l    #1,ptr(a4)
  5705.         moveq    #'.',d0
  5706.         bsr    putchar
  5707.         move.l    d2,d0
  5708.         bsr    hexa
  5709.         bra    newline
  5710.  
  5711. alert        move.l    excpttask(a4),d0
  5712.         bne.s    alert1
  5713.         move.w    #noguru,d0
  5714.         bra    putnamw
  5715. alert1        move.w    #softfail,d0
  5716.         bsr    putstrw
  5717.         move.l    excpttask(a4),d0
  5718.         bsr    getaskname2
  5719.         bsr    newline
  5720.         moveq    #3,d0
  5721.         cmp.l    excpterror(a4),d0
  5722.         bne.s    1$
  5723.         move.w    #addrserr,d0
  5724.         bsr    putstrw
  5725.         move.l    excptaddr(a4),d0
  5726.         bsr    hexa
  5727.         bsr    newline
  5728. 1$        move.w    #procount,d0
  5729.         bsr    putstrw
  5730.         move.l    excptpc(a4),d0
  5731.         bsr    hexa
  5732.         bsr    newline
  5733.         move.w    #gurutxt,d0
  5734.         bsr    putstrw
  5735.         move.l    excpterror(a4),d0
  5736.         bsr    hexa
  5737.         lea     out(a4),a0
  5738.         move.l    ptr(a4),d0
  5739.         move.b    #'.',-1(a0,d0.w)
  5740.         move.l    excpttask(a4),d0
  5741.         bsr    hexa
  5742.         bra    newline
  5743.  
  5744. showguru    bsr    stoptimer
  5745.         bsr    alert
  5746.         move.w    #_LVOScreenToFront,d0
  5747.         move.l    screenptr(a4),a0
  5748.         tst.b    ownscreen(a4)
  5749.         bne.s    5$
  5750.         move.w    #_LVOWindowToFront,d0
  5751.         move.l    wnptr(a4),a0
  5752. 5$        move.l    intuibase(a4),a6
  5753.         jsr    0(a6,d0.w)        ; Window or Screen ToFront()
  5754.  
  5755.         move.w    #whatnow,d0
  5756.         bsr    putnamw
  5757.         clr.l    oldpageend(a4)
  5758. 2$        bsr    readline
  5759.         cmp.b    #'i',d0
  5760.         beq.s    4$
  5761.         cmp.b    #'k',d0
  5762.         bne.s    2$
  5763.  
  5764.         move.l    excpttask(a4),a1
  5765.         tst.l    22(a1)
  5766.         bne.s    3$
  5767.         CALL    RemTask,sysbase(a4)
  5768.         bra.s    4$
  5769. 3$        move.l    a1,d0
  5770.         bsr    canok
  5771. 4$        clr.l    lastprinted(a4)
  5772.         bsr    starttimer
  5773.         rts
  5774.  
  5775. coldreboot    move.w    #$4000,$dff09a
  5776.         move.l    sysbase(a4),a6
  5777.         neg.w    82(a6)            ; kill ChkSum
  5778.         clr.l    4            ; kill ExecBase Ptr
  5779. reboot        move.l    sysbase(a4),a6
  5780.         tst.b    post_V34(a4)
  5781.         beq.s    1$
  5782.         jmp    _LVOColdReboot(a6)
  5783.  
  5784. 1$        lea    $01000004,a2        ; reboot manually
  5785.         suba.l    24(a2),a2
  5786.         movea.l    0(a2),a2
  5787.         subq.l    #2,a2
  5788.         lea    2$(pc),a5
  5789.         jmp    _LVOSupervisor(a6)
  5790.         cnop    0,4
  5791. 2$        reset
  5792.         jmp    0(a2)
  5793.  
  5794. ;save the contents of the output buffer
  5795. ;to a file, append the output if the file allready exists
  5796. saveoutput    bsr    nodenam2
  5797.         tst.b    0(a5)
  5798.         beq    syntax
  5799.         move.l    a5,d1
  5800.         move.l    #1004,d2        ; mode_readwrite
  5801.         CALL    Open,dosbase(a4)
  5802.         move.l    d0,d5
  5803.         beq.s    5$
  5804.         move.l    d5,d1
  5805.         moveq    #0,d2
  5806.         moveq    #1,d3
  5807.         RECALL    Seek
  5808.         bra.s    1$
  5809. 5$        move.l    a5,d1
  5810. ;        move.w    #1006,d2        ; mode_newfile
  5811.         addq.w    #2,d2
  5812.         RECALL    Open
  5813.         move.l    d0,d5
  5814.         bne.s    1$
  5815.         move.w    #openerr,d0
  5816.         bsr    putstrw
  5817.         move.l    a5,d0
  5818.         bra    putnam
  5819. 1$        move.l    outchain(a4),d0
  5820.         beq.s    3$
  5821. 2$        move.l    d0,a5
  5822.         move.w    12(a5),d3
  5823.         beq.s    4$
  5824.         ext.l    d3
  5825.         lea    14(a5),a0
  5826.         move.l    a0,d2
  5827.         move.l    d5,d1
  5828.         RECALL    Write
  5829.         tst.l    d0
  5830.         ble.s    3$
  5831. 4$        move.l    d5,d1
  5832.         lea     cr(a4),a0
  5833.         move.l    a0,d2
  5834.         moveq    #1,d3
  5835.         RECALL    Write
  5836.         tst.l    d0
  5837.         ble.s    3$
  5838.         move.l    0(a5),d0
  5839.         bne.s    2$
  5840. 3$        move.l    d5,d1
  5841.         RECALL    Close
  5842.         rts
  5843.  
  5844. grabtimerio    lea    tiohead(a4),a0
  5845.         bsr    puthead
  5846.         move.b    timeout(a4),d4
  5847.         st    timeout(a4)        ; 255 !
  5848.         bsr    starttimer
  5849.         move.b  d4,timeout(a4)
  5850.         pea    dummy(a4)
  5851.  
  5852.         CALL    Disable,sysbase(a4)
  5853.         lea    timerio(a4),a5
  5854. 6$        move.l    0(a5),a5
  5855.         tst.l    0(a5)            ; not lh_Tail
  5856.         bne.s    6$
  5857.         subq.l    #4,a5            ; now list header !
  5858.         RECALL    Enable
  5859.  
  5860.         bsr    stoptimer
  5861.         lea    buffer(a4),a3
  5862.         moveq    #1,d4            ; VBlank
  5863.         bsr    gettrq
  5864.  
  5865.         moveq    #40,d0
  5866.         lea    timerio(a4),a0
  5867.         move.l    (sp),a1            ; dummy
  5868.         RECALL    CopyMemQuick
  5869.  
  5870.         moveq    #0,d1
  5871.         moveq    #0,d0
  5872.         lea     timername(a4),a0
  5873.         move.l    (sp),a1            ; dummy
  5874.         RECALL    OpenDevice
  5875.  
  5876.         move.l    (sp),a1            ; dummy
  5877.         move.l    #1<<30,32(a1)
  5878.         RECALL    SendIO
  5879.  
  5880.         RECALL    Disable
  5881.         move.l    (sp),a5            ; dummy
  5882. 5$        move.l    0(a5),a5
  5883.         tst.l    0(a5)
  5884.         bne.s    5$
  5885.         subq.l    #4,a5            ; now list header !
  5886.         RECALL    Enable
  5887.         move.l    (sp),a1            ; dummy
  5888.         bsr    stoptimer2
  5889.         moveq    #0,d4            ; MicroHz
  5890.         bsr    gettrq
  5891.  
  5892.         move.l    (sp),a1            ; dummy
  5893.         RECALL    CloseDevice
  5894.  
  5895.         clr.l    (a3)
  5896.         lea    -18(a3),a2
  5897.         moveq    #18,d2
  5898.         bsr    sortlist
  5899.  
  5900.         move.l    (sp)+,a0        ; dummy
  5901.  
  5902.         tst.b    post_V34(a4)
  5903.         beq.s    3$            ; "black magic" needed? ;-(
  5904.  
  5905.         CALL    ReadEClock,timerio+20(a4)
  5906.         move.l    dummy+4(a4),d2
  5907.         move.l    d0,d3            ; EClock
  5908.         lea    buffer(a4),a2
  5909. 4$        move.l    0(a2),d0
  5910.         beq.s    3$
  5911.         move.l    10(a2),d0
  5912.         sub.l    d2,d0
  5913.         scc    d1
  5914.         ext.w    d1
  5915.         ext.l    d1
  5916.         and.l    d1,d0
  5917.         move.l    d3,d1
  5918.         bsr    div
  5919.         movem.l    d0/d1,6(a2)
  5920.         lea    18(a2),a2
  5921.         bra.s    4$
  5922.  
  5923. 3$        lea    buffer(a4),a5
  5924. 2$        move.l    (a5)+,d0
  5925.         beq.s    1$
  5926.         bsr    hexa
  5927.         move.w    (a5)+,d0
  5928.         ext.l    d0
  5929.         mulu    #9,d0
  5930.         add.w     #timerunits,d0
  5931.         bsr    putstrw
  5932.         move.l    (a5)+,d0
  5933.         bsr    putstamp
  5934.         moveq    #'.',d0
  5935.         bsr    putchar
  5936.         move.l    (a5)+,d0
  5937.         move.l    #100000,d1
  5938.         bsr    div
  5939.         or.b    #'0',d0
  5940.         bsr    putchar
  5941.         bsr    putblank
  5942.         move.l    (a5)+,d0
  5943.         bsr    getaskname2
  5944.         bsr    newline
  5945.         bra.s    2$
  5946. 1$        rts
  5947.  
  5948. gettrq        RECALL    Disable            ; a6 - SysBase
  5949. 3$        move.l    0(a5),a5
  5950.         tst.l    0(a5)
  5951.         beq.s    4$
  5952.         move.l    a5,(a3)+
  5953.         move.w    d4,(a3)+
  5954.         move.l    32(a5),(a3)+
  5955.         move.l    36(a5),(a3)+
  5956.         move.l    14(a5),a1
  5957.         move.l    16(a1),(a3)+
  5958.         bra.s    3$
  5959. 4$        RECALL    Enable
  5960.         rts
  5961.  
  5962. ; check if the timer is runnig, start it if not
  5963. starttimer    lea    timerio(a4),a1
  5964.         cmp.b    #5,8(a1)
  5965.         beq.s    1$
  5966.         moveq    #0,d0
  5967.         move.b    timeout(a4),d0
  5968.         bne.s    2$
  5969.         tst.l    timeoutm(a4)
  5970.         beq.s    1$
  5971. 2$        move.l    d0,32(a1)
  5972.         move.l    timeoutm(a4),36(a1)
  5973.         move.w    #9,28(a1)
  5974.         CALL    SendIO,sysbase(a4)
  5975. 1$        rts
  5976.  
  5977. ; Abort a timer request, if pending
  5978. stoptimer    move.l    sysbase(a4),a6
  5979.         lea    timerio(a4),a1
  5980.         cmp.b    #5,8(a1)
  5981.         bne.s    stptim
  5982. stoptimer2    move.l    a1,-(sp)
  5983.         RECALL    AbortIO
  5984.         move.l    (sp)+,a1
  5985.         RECALL    WaitIO
  5986. stptim        move.w    timersig(a4),d0
  5987.         moveq    #0,d1
  5988.         bset    d0,d1
  5989.         moveq    #0,d0
  5990.         jmp    _LVOSetSignal(a6)    ; clr signal
  5991.  
  5992. ;install as commodity and/or a input-handler
  5993. installh    move.l    cxbase(a4),d0        ; commodity possible ?
  5994.         beq    1$
  5995.         lea    broker(a4),a3
  5996.         lea    hotkeybuf(a4),a5
  5997.         move.l    d0,a6            ; cxbase
  5998.         moveq    #0,d0
  5999.         suba.l    a0,a0
  6000.         bsr    CreatePort
  6001.         move.l    d0,newbroker+20(a4)
  6002.         beq    1$
  6003.         move.l    d0,a0
  6004.         move.b    15(a0),cxsig+1(a4)
  6005.         moveq    #0,d0
  6006.         lea    newbroker(a4),a0
  6007.         RECALL    CxBroker
  6008.         move.l    d0,0(a3)
  6009.         beq.s    1$            ; no broker !
  6010.         moveq    #1,d0            ; CX_Filter
  6011.         move.l    a5,a0
  6012.         suba.l    a1,a1
  6013.         RECALL    CreateCxObj
  6014.         move.l    d0,filter(a4)
  6015.         beq.s    3$
  6016.         move.l    d0,a2
  6017.         move.l    d0,a0
  6018.         RECALL    CxObjError
  6019.         tst.l    d0
  6020.         beq.s    4$            ; hotkey definition ok !
  6021.         move.l    a5,a1
  6022.         lea    defhotkey(a4),a0
  6023. 5$        move.b    (a0)+,(a5)+        ; copy string
  6024.         bne.s    5$
  6025.         move.l    a2,a0
  6026.         RECALL    SetFilter        ; try our default
  6027. 4$        moveq    #4,d0            ; CX_Signal
  6028.         move.l    mytask(a4),a0
  6029.         move.w    #mysigbit,a1
  6030.         RECALL    CreateCxObj
  6031.         move.l    d0,a1            ; Signal -> Filter
  6032.         move.l    a2,a0
  6033.         RECALL    AttachCxObj
  6034.         moveq    #5,d0            ; CX_Translate
  6035.         suba.l    a0,a0
  6036.         suba.l    a1,a1
  6037.         RECALL    CreateCxObj
  6038.         move.l    d0,a1            ; Translate -> Filter
  6039.         move.l    a2,a0
  6040.         RECALL    AttachCxObj
  6041.         move.l    a2,a1            ; Filter -> Broker
  6042.         move.l    0(a3),a0
  6043.         RECALL    AttachCxObj
  6044. 3$        move.l    0(a3),a0        ; broker
  6045.         RECALL    CxObjError
  6046.         tst.l    d0
  6047.         beq.s    2$            ; no error
  6048.         move.l    0(a3),a0
  6049.         RECALL    DeleteCxObjAll
  6050.         clr.l    0(a3)            ; clear ptr
  6051. 2$        move.l    0(a3),d0
  6052.         beq.s    1$
  6053.         move.l    d0,a0
  6054.         moveq    #1,d0
  6055.         RECALL    ActivateCxObj
  6056.  
  6057. 1$        moveq    #0,d0
  6058.         suba.l    a0,a0
  6059.         bsr    CreatePort
  6060.         move.l    d0,inputport(a4)
  6061.         beq.s    6$
  6062.         bsr    CreateStdIO
  6063.         move.l    d0,inputio(a4)
  6064.         beq.s    6$
  6065.         move.l    d0,a1
  6066.         lea    inputname(a4),a0
  6067.         moveq    #0,d0
  6068.         moveq    #0,d1
  6069.         CALL    OpenDevice,sysbase(a4)
  6070.         tst.b    d0
  6071.         bne.s    6$
  6072.         st    inputdev(a4)
  6073.         lea    ininterrupt(a4),a0
  6074.         move.l    a4,14(a0)
  6075.         movea.l    inputio(a4),a1
  6076.         move.w    #9,28(a1)
  6077.         move.l    a0,40(a1)
  6078.         RECALL    DoIO
  6079.         moveq    #1,d0
  6080.         rts
  6081.  
  6082. 6$        moveq    #0,d0
  6083.         rts
  6084.  
  6085. ;change our commodity popkey
  6086. cxpopkey    bsr    nodenam2
  6087.         lea    hotkeybuf(a4),a3
  6088.         move.l    filter(a4),a2
  6089.         move.b    fromfile(a4),d7
  6090.         bne.s    3$            ; script
  6091.         tst.l    broker(a4)
  6092.         beq.s    1$            ; no broker - ignore
  6093.         move.l    a2,a0
  6094.         move.l    a5,a1
  6095.         CALL    SetFilter,cxbase(a4)    ; set new popkey
  6096.         move.l    a2,a0
  6097.         RECALL    CxObjError
  6098.         tst.l    d0
  6099.         beq.s    3$            ; no error
  6100.         move.l    a2,a0
  6101.         move.l    a3,a1
  6102.         RECALL    SetFilter        ; set old popkey
  6103.         move.l    a3,a5
  6104. 3$        moveq    #39,d0
  6105. 2$        move.b    (a5)+,(a3)+
  6106.         dbeq    d0,2$
  6107.         clr.b    (a3)
  6108.         tst.b    d7            ; script ?
  6109.         bne.s    1$
  6110.         bsr    setwintitle        ; show popkey
  6111. 1$        rts
  6112.  
  6113. ;remove commodity and/or handler
  6114. removeh        move.l    broker(a4),d2
  6115.         beq.s    5$            ; no commodity !
  6116.         move.l    d2,a0
  6117.         moveq    #0,d0            ; disable
  6118.         CALL    ActivateCxObj,cxbase(a4)
  6119.         move.l    d2,a0
  6120.         RECALL    DeleteCxObjAll
  6121. 5$        move.l    newbroker+20(a4),d0
  6122.         bsr.s    2$
  6123.         move.l    inputio(a4),d0
  6124.         beq.s    3$
  6125.         move.l    d0,a2
  6126.         tst.b    inputdev(a4)
  6127.         beq.s    4$
  6128.         move.l    a2,a1
  6129.         move.w    #10,28(a1)
  6130.         lea    ininterrupt(a4),a0
  6131.         move.l    a0,40(a1)
  6132.         CALL    DoIO,sysbase(a4)
  6133.         move.l    a2,a1
  6134.         RECALL    CloseDevice
  6135. 4$        move.l    a2,d0
  6136.         bsr    DeleteStdIO
  6137. 3$        move.l    inputport(a4),d0
  6138. 2$        beq.s    1$
  6139.         bsr    DeletePort
  6140. 1$        rts
  6141.  
  6142. ;check broker port for messages from master control 'Exchange'
  6143. ChkBroker    move.l    a2,-(sp)
  6144.         tst.l    broker(a4)
  6145.         beq.s    1$
  6146. 5$        move.l    newbroker+20(a4),a0
  6147.         CALL    GetMsg,sysbase(a4)
  6148.         move.l    d0,a2
  6149.         move.l    a2,d0
  6150.         beq.s    1$
  6151.         move.l    a2,a0
  6152.         CALL    CxMsgType,cxbase(a4)
  6153.         cmp.w    #$40,d0            ; CXM_COMMAND
  6154.         bne.s    2$
  6155.         move.l    a2,a0
  6156.         RECALL    CxMsgID
  6157.         move.l    mysignal(a4),d1
  6158.         cmp.w    #25,d0            ; CXCMD_UNIQUE
  6159.         beq.s    3$
  6160.         cmp.w    #23,d0            ; CXCMD_KILL
  6161.         seq    wantexit(a4)
  6162.         beq.s    4$
  6163.         cmp.w    #19,d0            ; CXCMD_APPEAR
  6164.         beq.s    3$
  6165.         moveq    #0,d1
  6166.         cmp.w    #21,d0            ; CXCMD_DISAPPEAR
  6167.         bne.s    3$
  6168.         st    wanthold(a4)
  6169. 4$        st    cbreak(a4)        ; end snooping (if necessary)
  6170.         move.w    nspubsig+6(a4),d0
  6171.         bset    d0,d1
  6172. 3$        move.l    d1,d0
  6173.         CALL    SetSignal,sysbase(a4)    ; set new signals
  6174. 2$        move.l    a2,a1
  6175.         CALL    ReplyMsg,sysbase(a4)
  6176.         bra.s    5$
  6177. 1$        move.l    (sp)+,a2
  6178.         rts
  6179.  
  6180. ;this is the handler, it checks if amiga-amiga-x
  6181. ;has been pressed and signals it to our task
  6182. keyhandler    move.l    a0,-(sp)
  6183.         tst.l    broker(a1)
  6184.         beq.s    2$        ; not running as commodity !
  6185.         tst.b    cxstate(a1)
  6186.         bne.s    1$        ; handler is off
  6187. 2$        cmp.b    #1,4(a0)
  6188.         bne.s    1$
  6189.         move.w    8(a0),d0
  6190.         andi.w    #$c0,d0
  6191.         cmpi.w    #$c0,d0
  6192.         bne.s    1$
  6193.         cmp.w    #$32,6(a0)
  6194.         bne.s    1$
  6195.         clr.b    4(a0)        ; nop event
  6196.         bsr.s    wakeup
  6197. 1$        move.l    (sp)+,d0    ; return event
  6198.         rts
  6199.  
  6200. ;wakeup Xoper
  6201. wakeup        move.l    mysignal(a1),d0
  6202.         move.l    sysbase(a1),a6
  6203.         movea.l    mytask(a1),a1
  6204.         jmp    _LVOSignal(a6)
  6205.  
  6206. ;ports-handler
  6207. countio        addq.l    #1,iocount(a1)
  6208.         tst.b    pcheck(a1)
  6209.         beq.s    1$            ; check not requested
  6210.         bsr.s    checkit
  6211.         tst.b    d1
  6212.         beq.s    1$
  6213.         clr.b    pcheck(a1)        ; disable checking ...
  6214.         bsr.s    wakeup
  6215. 1$        moveq    #0,d0
  6216.         rts
  6217.  
  6218. checkit        moveq    #0,d1            ; check all patched functions
  6219.         move.l    sysbase(a1),a6        ; exec library
  6220.         tst.b    bool(a1)
  6221.         beq.s    5$
  6222.         lea    myswitch(pc),a5
  6223.         move.w    #_LVOSwitch,d0
  6224.         bsr.s    2$
  6225.         lea    myaddtask(pc),a5
  6226.         move.w    #_LVOAddTask,d0
  6227.         bsr.s    2$
  6228. 5$        tst.b    msnoop(a1)
  6229.         beq.s    4$
  6230.         lea    capmalloc(pc),a5
  6231.         move.w    #_LVOAllocMem,d0
  6232.         bsr.s    2$
  6233.         lea    capmfree(pc),a5
  6234.         move.w    #_LVOFreeMem,d0
  6235.         bsr.s    2$
  6236. 4$        move.l    dosbase(a1),a6        ; dos library
  6237.         tst.b    DosTable+05(a1)
  6238.         beq.s    3$
  6239.         move.l    DosTable+16(a1),a5
  6240.         move.w    DosTable+00(a1),d0
  6241.         bsr.s    2$
  6242. 3$        tst.b    DosTable+25(a1)
  6243.         beq.s    1$
  6244.         move.l    DosTable+36(a1),a5
  6245.         move.w    DosTable+20(a1),d0
  6246. 2$        cmp.l    2(a6,d0.w),a5        ; check library function
  6247.         seq    d1
  6248. 1$        rts
  6249.  
  6250. ;compare strings
  6251. ; -> a0/a1 = pointers to string
  6252. ; <- d0 = true(0) false(1), d1 = length
  6253.  
  6254. strcmp        movem.l    d2/a0/a1,-(sp)
  6255.         moveq    #0,d0
  6256.         moveq    #0,d1
  6257. src2        move.b    (a0)+,d0
  6258.         beq.s    src1
  6259.         cmp.b    #10,d0
  6260.         beq.s    src1
  6261.         bsr.s    src4
  6262.         move.b    d0,d2
  6263.         move.b    (a1)+,d0
  6264.         bsr.s    src4
  6265.         cmp.b    d2,d0
  6266.         bne.s    src3
  6267.         addq.w    #1,d1
  6268.         bra.s    src2
  6269. src1        move.b    0(a1),d0
  6270. src3        movem.l    (sp)+,d2/a0/a1
  6271.         rts
  6272.  
  6273. src4        cmp.b    #'z'+1,d0        ; convert to upper case
  6274.         bcc.s    1$
  6275.         cmp.b    #'a',d0
  6276.         bcs.s    1$
  6277.         add.b    #$e0,d0
  6278. 1$        rts
  6279.  
  6280. strbuf        movem.l    d0/a1-a2,-(sp)
  6281.         move.l    a0,a1
  6282.         lea    buffer(a4),a2
  6283. 1$        move.b    (a1)+,d0
  6284.         cmp.b    #10,d0
  6285.         beq.s    2$
  6286.         cmp.b    #' ',d0
  6287.         beq.s    2$
  6288.         or.b    #' ',d0
  6289.         beq.s    2$
  6290.         move.b    d0,(a2)+
  6291.         bra.s    1$
  6292. 2$        clr.b    (a2)+
  6293.         movem.l    (sp)+,d0/a1-a2
  6294.         rts
  6295.  
  6296. tolower        movem.l    d0-d1/a0,-(sp)
  6297.         subq.w    #1,d0
  6298.         bmi.s    3$
  6299. 1$        move.b    0(a0),d1
  6300.         cmp.b    #'A',d1
  6301.         blt.s    2$
  6302.         cmp.b    #'Z',d1
  6303.         bgt.s    2$
  6304.         or.b    #' ',d1
  6305. 2$        move.b    d1,(a0)+
  6306.         dbra    d0,1$
  6307. 3$        clr.b    (a0)
  6308.         movem.l    (sp)+,d0-d1/a0
  6309.         rts
  6310.  
  6311. div        tst.l    d1
  6312.         beq.s    1$
  6313.         move.l    div32(a4),-(sp)
  6314. 1$        rts
  6315.  
  6316. ; 32-bit division d0 / d1
  6317. ; <- d0 - result
  6318. ;    d1 - remainder
  6319.  
  6320. div68020    dc.w    $4c41,$0001        ; divul.l d1,d1:d0
  6321.         rts
  6322.  
  6323. div68000    move.l    d3,-(sp)
  6324.         move.l    d2,-(sp)
  6325.         move.l    d1,d3
  6326.         swap    d1
  6327.         tst.w    d1
  6328.         bne.s    4$
  6329.         move.w    d0,d2
  6330.         clr.w    d0
  6331.         swap    d0
  6332.         divu.w    d3,d0
  6333.         move.l    d0,d1
  6334.         swap    d0
  6335.         move.w    d2,d1
  6336.         divu.w    d3,d1
  6337.         move.w    d1,d0
  6338.         clr.w    d1
  6339.         swap    d1
  6340.         bra.s    1$
  6341. 4$        move.l    d0,d1
  6342.         swap    d0
  6343.         clr.w    d0
  6344.         clr.w    d1
  6345.         swap    d1
  6346.         moveq    #16-1,d2
  6347. 3$        add.l    d0,d0
  6348.         addx.l    d1,d1
  6349.         cmp.l    d1,d3
  6350.         bhi.s    2$
  6351.         sub.l    d3,d1
  6352.         addq.w    #1,d0
  6353. 2$        dbra    d2,3$
  6354. 1$        move.l    (sp)+,d2
  6355.         move.l    (sp)+,d3
  6356.         rts
  6357.  
  6358. ;copy a string from input to 'buffer'
  6359. ; -> a0 = pointer to string
  6360. getstr        lea    buffer(a4),a5
  6361. 1$        cmp.b    #' ',0(a0)
  6362.         beq.s    2$
  6363.         cmp.b    #10,0(a0)
  6364.         beq.s    2$
  6365.         move.b    (a0)+,(a5)+
  6366.         bra.s    1$
  6367. 2$        clr.b     0(a5)
  6368.  
  6369. ;skip blanks
  6370. ; -> a0 pointer to text
  6371. ; <- a0 = new pointer position
  6372. kllblnks    cmpi.b    #' ',(a0)+
  6373.         beq.s    kllblnks
  6374.         subq.w    #1,a0
  6375.         rts
  6376.  
  6377. ;read in a nodename or a processname
  6378. nodenam        bsr.s    isdec
  6379.         move.w    d2,procnum(a4)
  6380. nodenam2    bsr.s    kllblnks
  6381.         move.l    a0,a5
  6382. gno1        cmp.b    #10,(a0)+
  6383.         bne.s    gno1
  6384.         clr.b    -1(a0)
  6385.         rts
  6386.  
  6387. getfrac        bsr.s    isdec
  6388.         moveq    #0,d0
  6389.         cmp.b    #'.',(a0)
  6390.         bne.s    1$
  6391.         addq.w    #1,a0
  6392.         cmp.b    #10,(a0)
  6393.         beq.s    1$
  6394.         move.b    (a0)+,d0
  6395.         and.b    #$0f,d0
  6396.         moveq    #1,d7
  6397. 1$        muls    #10,d2
  6398.         add.l    d0,d2
  6399.         rts
  6400.  
  6401. ;convert ascii to byte
  6402. ; -> a0 = pointer to text
  6403. ; <- d0 = byte
  6404. getnum        bsr.s    kllblnks
  6405.         cmp.b    #'$',0(a0)
  6406.         bne.s    isdec
  6407.         bsr.s    readhex
  6408.         move.l    d0,d2
  6409.         rts
  6410. isdec        moveq    #0,d2
  6411.         moveq    #0,d3
  6412.         moveq    #0,d6
  6413.         moveq    #0,d7
  6414.         cmp.b    #'-',0(a0)
  6415.         bne.s    gn1
  6416.         addq.w    #1,a0
  6417.         moveq    #1,d6
  6418. gn1        move.b    (a0)+,d3
  6419.         cmp.b    #'9',d3
  6420.         bhi.s    gn2
  6421.         cmp.b    #'0',d3
  6422.         bcs.s    gn2
  6423.         moveq     #1,d7
  6424.         and.b    #$f,d3
  6425.         muls    #10,d2
  6426.         add.l    d3,d2
  6427.         bra.s    gn1
  6428. gn2        tst.b    d6
  6429.         beq.s    gn3
  6430.         neg.l    d2
  6431. gn3        subq.w    #1,a0
  6432.         rts
  6433.  
  6434. ;convert hex to longword
  6435. ; -> a0 = pointer to text
  6436. ; <- d0=value, d7 = ok(1) error(0)
  6437. readhex        movem.l    d1-d6/a1-a5,-(sp)
  6438.         moveq    #1,d7
  6439.         cmp.b    #'$',0(a0)
  6440.         bne.s    rh3
  6441.         addq.l    #1,a0
  6442. rh3        moveq    #0,d0
  6443.         cmpi.b    #10,0(a0)
  6444.         beq.s    rherr
  6445.         lea    hextab(a4),a1
  6446. rh0        move.b    (a0)+,d3
  6447.         moveq.l    #15,d2
  6448. rh1        cmp.b    0(a1,d2.w),d3
  6449.         beq.s    rh2
  6450.         dbra    d2,rh1
  6451.         bra.s    rhend
  6452. rh2        lsl.l    #4,d0
  6453.         or.b    d2,d0
  6454.         bra.s    rh0
  6455. rhend        tst.b    d3
  6456.         beq.s    rhok
  6457.         cmpi.b    #10,d3
  6458.         beq.s    rhok
  6459.         cmpi.b    #' ',d3
  6460.         beq.s    rhok
  6461. rherr        moveq    #0,d7
  6462. rhok        movem.l    (sp)+,d1-d6/a1-a5
  6463.         rts
  6464.  
  6465. longdecn    move.l    d3,-(sp)
  6466.         moveq    #3,d3
  6467.         bsr.s    longdec
  6468.         move.l    (sp)+,d3
  6469.         move.w    #binarea+9,d0
  6470.         sub.w    d3,d0
  6471.         bra    putstrw
  6472.  
  6473. ;convert long to decimal
  6474. ; -> d0 = value
  6475. ;    d3 bit 0 = left/right justified
  6476. ;       bit 1 = write/leave
  6477. ; returns string in 'buffer'
  6478. longdec        movem.l    d1-d2/a1-a2,-(sp)
  6479.         tst.l    d0
  6480.         bmi.s    2$
  6481.         cmp.l    #999999999,d0
  6482.         ble.s    1$
  6483. 2$        move.w    #longlongnix,d0
  6484.         bra.s    ld6
  6485. 1$        lea    binarea(a4),a1
  6486.         move.l    #'    ',(a1)+
  6487.         move.l    #'    ',(a1)+
  6488.         move.w    #'  ',(a1)+
  6489.         clr.b    0(a1)
  6490.         subq.w    #1,a1
  6491.         cmp.w    #2,d3
  6492.         bne.s    ld5
  6493.         clr.b    0(a1)
  6494. ld5        moveq    #1,d2
  6495. ld2        addq.w    #1,d2
  6496.         moveq    #10,d1
  6497.         bsr    div
  6498.         addi.b    #'0',d1
  6499.         move.b    d1,-(a1)
  6500.         tst.l    d0
  6501.         bne.s    ld2
  6502.         btst    #0,d3
  6503.         bne.s    ld1
  6504.         lea    binarea(a4),a2
  6505.         cmpa.l    a2,a1
  6506.         bne.s    ld3
  6507.         subq.l    #1,ptr(a4)
  6508.         bra.s    ld1
  6509. ld3        move.b    0(a1),(a2)+
  6510.         move.b    #' ',(a1)+
  6511.         dbra    d2,ld3
  6512. ld1        move.w    #binarea,d0
  6513. ld6        btst    #1,d3
  6514.         bne.s    ld4
  6515.         bsr    putstrw
  6516. ld4        movem.l    (sp)+,d1-d2/a1-a2
  6517.         rts
  6518.  
  6519. putlongascii    movem.l    d1/d2,-(sp)
  6520.         moveq    #3,d2
  6521.         move.l    d0,d1
  6522. 2$        rol.l    #8,d1
  6523.         move.b    d1,d0
  6524.         beq.s    1$
  6525.         bsr    putchar
  6526. 1$        dbra    d2,2$
  6527.         movem.l    (sp)+,d1/d2
  6528.         rts
  6529.  
  6530. putstamp    movem.l    d0/d1,-(sp)
  6531.         move.l    #3600,d1
  6532.         bsr    div
  6533.         moveq    #3,d3
  6534.         bsr    longdec
  6535.         move.l    binarea+6(a4),d0
  6536.         lsr.l    #8,d0
  6537.         bsr.s    putlongascii
  6538.         moveq    #':',d0
  6539.         bsr    putchar
  6540.         move.l    d1,d0
  6541.         moveq    #60,d1
  6542.         bsr    div
  6543.         bsr.s    write2digs
  6544.         moveq    #':',d0
  6545.         bsr    putchar
  6546.         move.l    d1,d0
  6547.         bsr.s    write2digs
  6548.         movem.l (sp)+,d0/d1
  6549.         rts
  6550.  
  6551. write2digs    movem.l    d0/d1,-(sp)
  6552.         divu    #10,d0
  6553.         move.l    d0,d1
  6554.         or.b    #'0',d0
  6555.         bsr    putchar
  6556.         swap    d1
  6557.         or.b    #'0',d1
  6558.         move.b    d1,d0
  6559.         bsr    putchar
  6560.         movem.l    (sp)+,d0/d1
  6561.         rts
  6562.  
  6563. ;print a bcpl-string
  6564. ; -> d0 = bcpl-pointer to bcpl-string
  6565. putbcpl        movem.l    d3/a0-a1,-(sp)
  6566.         tst.l    d0
  6567.         beq.s    1$
  6568.         lsl.l    #2,d0
  6569.         move.l    d0,a1
  6570.         moveq    #0,d3
  6571.         move.b    (a1)+,d3
  6572.         subq.w    #1,d3
  6573.         bmi.s    1$
  6574. 2$        move.b    (a1)+,d0
  6575.         beq.s    1$
  6576.         bsr    putchar
  6577.         dbra    d3,2$
  6578. 1$        move.l    ptr(a4),d0
  6579.         movem.l    (sp)+,d3/a0-a1
  6580.         rts
  6581.  
  6582. ;write unsigned word
  6583. ; -> d3 = value
  6584. worddec        bsr.s    dec2
  6585.         move.w    #minus+1,d0
  6586.         bra    putstrw
  6587.  
  6588. ;write unsigned byte
  6589. ; -> d3 = value
  6590. bytedec        bsr.s    dec1
  6591.         move.w    #decimal,d0
  6592.         bra    putstrw
  6593.  
  6594. ;write signed byte
  6595. ; -> d3 = value
  6596. plusmins    movem.l    d5/a3,-(sp)
  6597.         move.w    #$2020,minus(a4)
  6598.         move.b    d3,d5
  6599.         bpl.s    2$
  6600.         neg.b    d3
  6601. 2$        bsr.s    dec1
  6602.         tst.b    d5
  6603.         bpl.s    1$
  6604.         move.l    d0,a3
  6605.         move.b    #'-',-(a3)
  6606. 1$        movem.l    (sp)+,d5/a3
  6607.         move.w    #minus+1,d0
  6608.         bra    putstrw
  6609.  
  6610. dec2        movem.l    d3/a2/a3,-(sp)        ; convert word
  6611.         and.l    #$ffff,d3
  6612.         lea    minus(a4),a3
  6613.         move.w    #$2020,(a3)+
  6614.         bra.s    dec
  6615.  
  6616. dec1        movem.l    d3/a2/a3,-(sp)        ; convert byte
  6617.         and.l    #$ff,d3
  6618.         lea    decimal(a4),a3
  6619.  
  6620. dec        move.l    #$20203020,(a3)+
  6621.         subq.l    #1,a3
  6622.         move.l    a3,a2
  6623.         moveq    #'0',d0
  6624. 3$        tst.b    d3
  6625.         beq.s    2$
  6626.         divu    #10,d3
  6627.         swap    d3
  6628.         or.b    d0,d3
  6629.         move.b    d3,-(a3)
  6630.         clr.w    d3
  6631.         swap    d3
  6632.         bra.s    3$
  6633. 2$        cmpa.l    a2,a3
  6634.         bcs.s    1$
  6635.         move.b    d0,-(a3)
  6636. 1$        move.l    a3,d0
  6637.         movem.l    (sp)+,d3/a2/a3
  6638.         rts
  6639.  
  6640. prcent        lsl.l    #3,d0            ; 1000x=1024x-24x
  6641.         move.l    d0,d2
  6642.         add.l    d0,d0
  6643.         add.l    d0,d2
  6644.         lsl.l    #6,d0
  6645.         sub.l    d2,d0
  6646.         bsr    div
  6647.         moveq    #0,d5
  6648.         bsr.s    putfrac
  6649.         move.w    #infoh4,d0
  6650.         bra    putstrw
  6651.  
  6652. putfrac        divu    #10,d0
  6653.         move    d0,d3
  6654.         swap    d0
  6655.         move    d0,d1
  6656.         tst.w    d5
  6657.         bne.s    1$
  6658.         cmp.w    #100,d3
  6659.         ble.s    1$
  6660.         move.w    #whatsthis,d0
  6661.         bra    putstrw
  6662. 1$        bsr    bytedec
  6663.         lea    out(a4),a0
  6664.         move.b    #'.',-1(a0,d0)
  6665.         or.b    #'0',d1
  6666.         move    d1,d0
  6667.         bra    putchar
  6668.  
  6669. ;Write pointer, display '-------' if empty
  6670. hexan        tst.l    d0
  6671.         beq.s    hexa2
  6672.  
  6673. ;Write 8 byte hex value
  6674. ; -> d0 = value
  6675. hexa        bsr.s    gthex
  6676. hexa2        bra    putstr
  6677.  
  6678. gthex        movem.l    d1-d2/a1-a2,-(sp)
  6679.         lea    hexarea+9(a4),a2
  6680.         move.b    #' ',-(a2)
  6681.         lea    hextab(a4),a1
  6682.         moveq    #7,d2
  6683. hexloop     moveq    #$0f,d1
  6684.         and.b    d0,d1
  6685.         move.b    0(a1,d1.w),-(a2)
  6686.         lsr.l    #4,d0
  6687.         dbra    d2,hexloop
  6688.         move.l    a2,d0
  6689.         movem.l    (sp)+,d1-d2/a1-a2
  6690.         rts
  6691.  
  6692. ;Convert/write byte into binary string
  6693. ; -> d0 = value
  6694. bin        movem.l    d1-d7/a0-a6,-(sp)
  6695.         lea    binarea(a4),a0
  6696.         move.l    #$2020<<16,8(a0)
  6697.         moveq    #7,d4
  6698. binloop        moveq    #'0'/2,d1
  6699.         roxr.b    #1,d0
  6700.         roxl.b    #1,d1
  6701.         move.b    d1,0(a0,d4.w)
  6702.         dbra    d4,binloop
  6703.         move.l    a0,d0
  6704.         movem.l    (sp)+,d1-d7/a0-a6
  6705.         bra    putstr
  6706.  
  6707. ;look for NUL-Byte
  6708. strlen        moveq    #0,d0
  6709.  
  6710. ;look for character in d0
  6711. strlen2        move.l    a0,-(sp)
  6712. 1$        cmp.b    (a0)+,d0
  6713.         bne.s    1$
  6714.         move.l    a0,d0
  6715.         move.l    (sp)+,a0
  6716.         sub.l    a0,d0
  6717.         subq.l    #1,d0
  6718.         rts
  6719.  
  6720. ;write a title and underline
  6721. ; -> a0 = pointer to text
  6722. puthead1    bsr.s    strlen
  6723.         move.l    d0,d5
  6724.         move.l    a0,d0
  6725.         bra    putstr
  6726.  
  6727. puthead2    bsr.s    strlen
  6728.         add.l    d0,d5
  6729.         bra.s    ph2
  6730.  
  6731. puthead        bsr.s    strlen
  6732.         move.l    d0,d5
  6733. ph2        move.l    a0,d0
  6734.         bsr.s    putnam
  6735.         lea    out(a4),a0
  6736.         move.l    a0,d0
  6737. ph1        move.b    #'-',(a0)+
  6738.         dbra    d5,ph1
  6739.         move.b    #10,(a0)+
  6740.         clr.b    0(a0)
  6741.         bra.s    putstr
  6742.  
  6743. syntax        move.w    #synerr,d0        ; error
  6744.  
  6745. ;write a string, move cursor into next line
  6746. ; -> d0 = pointer to text
  6747. putnamw        bsr.s    putstrw
  6748.         bra.s    putnam1
  6749. putnam        bsr.s    putstr
  6750. putnam1        tst.b    d0
  6751.         beq.s    1$
  6752.         bsr.s    newline
  6753. 1$        rts
  6754.  
  6755. newline        move.w    #cr,d0            ; linefeed
  6756.  
  6757. ;write a string, strings are only put into the output buffer
  6758. ;when a LF is detected
  6759. ; -> d0 = pointer to string
  6760. ; <- d0 = cursor position
  6761.  
  6762. putstrw        ext.l    d0
  6763.         add.l    a4,d0            ; dataarea
  6764. putstr        movem.l    d1-d7/a0-a6,-(sp)
  6765.         st    printed(a4)
  6766.         move.l    d0,a2
  6767.         lea    out(a4),a3
  6768.         move.l    ptr(a4),d0
  6769.         move.l    a2,d5
  6770.         bne.s    pst1
  6771.         lea    longnix(a4),a2
  6772.  
  6773. pst1        move.b    (a2)+,d1
  6774.         cmpi.b    #13,d1
  6775.         beq.s    pst1
  6776.         cmpi.b    #10,d1
  6777.         beq.s    lineend
  6778.         move.b    d1,0(a3,d0.w)
  6779.         beq    prend
  6780.         cmp.w    #100+100,d0
  6781.         bge.s    pst1
  6782.         addq.l    #1,d0
  6783.         bra.s    pst1
  6784.  
  6785. lineend        tst.b    fromfile(a4)
  6786.         beq.s    1$
  6787.         moveq    #0,d0
  6788.         bra    prend
  6789.  
  6790. 1$        tst.l    lastprinted(a4)
  6791.         bne.s    2$
  6792.         bsr    killpage
  6793.  
  6794. 2$        addq.w    #1,d0
  6795.         move.l    d0,-(sp)
  6796.         add.w    #14,d0
  6797.         moveq    #0,d1
  6798.         CALL    AllocMem,sysbase(a4)
  6799.         move.l    (sp)+,d1
  6800.         tst.l    d0
  6801.         beq    prend
  6802.         move.l    d0,a0
  6803.         move.w    d1,12(a0)
  6804.         cmp.w    maxllength(a4),d1
  6805.         ble.s    7$
  6806.         move.w    d1,maxllength(a4)
  6807. 7$        move.l    node(a4),8(a0)
  6808.         clr.l    node(a4)
  6809.         clr.l    0(a0)
  6810.         move.l    lastprinted(a4),d0
  6811.         move.l    d0,4(a0)
  6812.         bne.s    3$
  6813.         move.l    a0,outchain(a4)
  6814.         bra.s    4$
  6815. 3$        move.l    d0,a1
  6816.         move.l    a0,0(a1)
  6817. 4$        move.l    a0,lastprinted(a4)
  6818.         lea    out(a4),a1
  6819.         lea    14(a0),a0
  6820.         move.b    #' ',(a0)+
  6821.         subq.w    #2,d1
  6822.         bmi.s    6$
  6823. 5$        move.b    (a1)+,(a0)+
  6824.         dbra    d1,5$
  6825. 6$        move.l    numlines(a4),d2
  6826.         cmp.l    maxlines(a4),d2
  6827.         ble.s    8$
  6828.         move.l    outchain(a4),a1        ; maxlines reached !
  6829.         move.l    0(a1),a0
  6830.         move.l    a0,outchain(a4)
  6831.         clr.l    4(a0)
  6832.         moveq    #14,d0
  6833.         add.w    12(a1),d0
  6834.         CALL    FreeMem,sysbase(a4)
  6835.         bra.s    9$
  6836.  
  6837. 8$        addq.l    #1,numlines(a4)
  6838. 9$        moveq    #0,d0
  6839.         tst.b    addlines(a4)
  6840.         beq.s    10$
  6841.         bsr    addline
  6842. 10$        bra    pst1
  6843. prend        move.l    d0,ptr(a4)
  6844.         movem.l    (sp)+,d1-d7/a0-a6
  6845.         rts
  6846.  
  6847. putblank    moveq    #' ',d0            ; store one blank
  6848.  
  6849. ;write one char 
  6850. ; -> d0 = char
  6851. putchar        movem.l    d1/a1,-(sp)
  6852.         move.l    ptr(a4),d1
  6853.         lea    out(a4),a1
  6854.         move.b    d0,0(a1,d1.w)
  6855.         addq.l    #1,ptr(a4)
  6856.         movem.l    (sp)+,d1/a1
  6857.         rts
  6858.  
  6859. ;move cursor to a column
  6860. ; -> d0 = current position
  6861. ;    d1 = column
  6862. tab        move.l    a3,-(sp)
  6863.         lea    out(a4),a3
  6864. 1$        cmp.b    d1,d0
  6865.         bcc.s    2$
  6866.         move.b    #' ',0(a3,d0.w)
  6867.         addq.b    #1,d0
  6868.         bra.s    1$
  6869. 2$        move.l    d1,ptr(a4)
  6870.         move.l    (sp)+,a3
  6871.         rts
  6872.  
  6873. ; Xoper main loop, process all incoming messages
  6874. processmsgs    moveq    #0,d0
  6875.         move.w    cxsig(a4),d1
  6876.         beq.s    3$
  6877.         bset    d1,d0
  6878. 3$        move.w    nspubsig+6(a4),d1
  6879.         bset    d1,d0
  6880.         move.w    intuisig(a4),d1
  6881.         bset    d1,d0
  6882.         move.w    timersig(a4),d1
  6883.         bset    d1,d0
  6884.         ori.w    #$1000,d0
  6885.         or.l    mysignal(a4),d0
  6886.         or.l    auxsig(a4),d0
  6887.         tst.l    auxsig(a4)
  6888.         bne.s    2$
  6889.         or.l    trapmask(a4),d0
  6890. 2$        CALL    Wait,sysbase(a4)
  6891.  
  6892.         move.l    d0,tasksigs(a4)
  6893.  
  6894.         move.l    trapmask(a4),d1
  6895.         and.l    d0,d1
  6896.         beq.s    1$
  6897.         tst.b    gotguru(a4)
  6898.         bne.s    1$
  6899.         st    gotguru(a4)
  6900.         bsr    showguru
  6901.         clr.b    gotguru(a4)
  6902.  
  6903. 1$        bsr    ChkBroker        ; check broker port
  6904.  
  6905. ctrl_c        moveq    #12,d1
  6906.         bsr    testsig
  6907.         beq.s    pubscreen
  6908.         bsr    exitall            ; exit requested (break)
  6909.  
  6910. pubscreen    move.w    nspubsig+6(a4),d1
  6911.         bsr    testsig
  6912.         beq.s    hotkey
  6913.         pea    hotkey(pc)        ; return address (if necessary)
  6914.         tst.b    wantexit(a4)
  6915.         bne    exitall            ; exit requested
  6916.         tst.b    wanthold(a4)
  6917.         bne    instback        ; hold requested
  6918.         tst.b    wantwindow(a4)
  6919.         bne    usewindow        ; window requested
  6920.         addq.w    #4,sp
  6921.  
  6922. hotkey        moveq    #mysigbit,d1
  6923.         bsr    testsig
  6924.         beq.s    timermsg
  6925.         move.l    intuibase(a4),a6    ; Screen & window to front
  6926.         move.l    wnptr(a4),a2
  6927.         tst.b    ownscreen(a4)
  6928.         bne.s    1$            ; for scr window only activate !
  6929.         move.l    a2,a0
  6930.         RECALL    WindowToFront
  6931. 1$        move.l    a2,a0
  6932.         RECALL    ActivateWindow
  6933.         move.l    46(a2),a0        ; Window->Screen frontmost ?
  6934.         cmp.l    60(a6),a0
  6935.         beq.s    timermsg        ; yes, so skip !
  6936.         RECALL    ScreenToFront
  6937.  
  6938. timermsg    move.w    timersig(a4),d1
  6939.         bsr    testsig
  6940.         beq.s    intuimsgs
  6941.         btst    #8,propinfo(a4)
  6942.         bne.s    3$
  6943.         tst.b    repeat(a4)
  6944.         bne.s    1$
  6945.         bsr    showwhat
  6946.         bra.s    intuimsgs
  6947. 1$        move.w    repeatlen(a4),d0
  6948.         lea    repeatbuffer(a4),a2
  6949.         lea    dummy(a4),a1
  6950.         move.w    d0,d1
  6951. 2$        move.b    (a2)+,(a1)+
  6952.         dbra    d1,2$
  6953.         bsr    cli
  6954. 3$        bsr    starttimer
  6955.  
  6956. intuimsgs    move.w    intuisig(a4),d1
  6957.         bsr    testsig
  6958.         beq    processnxtmsg
  6959. nextimsg    move.l    wnptr(a4),a0
  6960.         move.l    $56(a0),a0
  6961.         CALL    GetMsg,sysbase(a4)
  6962.         move.l    d0,intuimsg(a4)
  6963.         beq    processnxtmsg
  6964.         move.l    d0,a0
  6965.         move.l    20(a0),d0
  6966.  
  6967.         cmp.l    #$200,d0        ; CloseWindow
  6968.         bne.s    1$
  6969.         tst.b    addlines(a4)
  6970.         beq    instback        ; iconify !
  6971.         st    cbreak(a4)
  6972.         bra    intuiend
  6973.  
  6974. 1$        moveq    #2,d1            ; ResizeWindow
  6975.         cmp.l    d1,d0
  6976.         bne.s    1010$
  6977.         bsr    setupscreen
  6978.         bra    intuiend
  6979.  
  6980. 1010$        moveq    #$10,d1            ; mousemove
  6981.         cmp.l    d1,d0
  6982.         bne.s    2$
  6983.         btst    #8,propinfo(a4)
  6984.         bne.s    1004$
  6985.         bra.s    1002$
  6986.  
  6987. 2$        moveq    #4,d1            ; refresh
  6988.         cmp.l    d1,d0
  6989.         bne.s    22$
  6990.         bsr    putiline
  6991.         bsr    blastout
  6992.         bsr    UpdateIArea
  6993.         bra.s    1002$
  6994.  
  6995. 22$        tst.b    addlines(a4)
  6996.         bne.s    3$
  6997.         moveq    #$20,d1            ; gadgetdown
  6998.         cmp.l    d1,d0
  6999.         bne.s    1000$
  7000.         tst.b    getanswer(a4)
  7001.         bne.s    3$
  7002.         move.l    28(a0),a1
  7003.         cmp.w    #3,38(a1)        ; Slidebar
  7004.         bne.s    1002$
  7005.         tst.b    propgadon(a4)
  7006.         beq.s    1002$
  7007. 1004$        bsr    proppos
  7008. 1002$        bra    intuiend
  7009.  
  7010. 1000$        moveq    #$40,d1            ; gadgetup
  7011.         cmp.l    d1,d0
  7012.         bne.s    3$
  7013.         move.l    28(a0),a1
  7014.         cmp.w    #3,38(a1)        ; Slidebar ?
  7015.         bne.s    1003$
  7016.         bclr    #8,propinfo(a4)        ; clear 'knop hit' bit
  7017.         bra.s    1002$
  7018.  
  7019. 1003$        bsr    replyintui        ; iconify
  7020.         bsr    stoptimer
  7021.         bra    instback
  7022.  
  7023. 3$        cmp.l    #$400,d0        ; RawKey
  7024.         bne    intuiend
  7025.         move.w    #$80,d0
  7026.         and.w    24(a0),d0
  7027.         bne    intuiend
  7028.         and.w    #$7f,24(a0)
  7029.         lea    ievent(a4),a1
  7030.         move.b    #1,4(a1)
  7031.         move.l    24(a0),6(a1)
  7032.         move.w    26(a0),qualifier(a4)
  7033.         move.l    a1,a0
  7034.         lea    outevent(a4),a1
  7035.         moveq    #20,d1
  7036.         suba.l    a2,a2
  7037.         CALL    RawKeyConvert,condev(a4)
  7038.         tst.l    d0
  7039.         beq    intuiend
  7040.         lea    inputbuffer(a4),a1
  7041.         lea    outevent(a4),a2
  7042.         move.w    curpos(a4),d4
  7043.         moveq    #0,d3
  7044.         tst.b    addlines(a4)
  7045.         bne    197$
  7046.  
  7047.         cmp.b    #$9b,0(a2)        ; SI code
  7048.         bne    110$
  7049.  
  7050.         cmp.b    #'?',1(a2)        ; help
  7051.         bne.s    399$
  7052.         tst.b    getanswer(a4)
  7053.         bne.s    399$
  7054.         bsr    stoptimer
  7055.         tst.w    bottomin(a4)
  7056.         bne.s    398$
  7057.         addq.w    #1,bottomin(a4)
  7058.         bsr    getcurpos
  7059.         clr.w    ibufferlen(a4)
  7060.         clr.w    curpos(a4)
  7061.         bsr    UpdateIArea
  7062. 398$        move.w    #usetxt,d0
  7063.         bsr    putnamw
  7064.         clr.l    lastprinted(a4)
  7065.         bsr    blastout
  7066.         bra.s    420$
  7067.  
  7068. 399$        cmp.b    #'C',1(a2)        ; cursor right
  7069.         bne.s    400$
  7070.         cmp.w    ibufferlen(a4),d4
  7071.         bge.s    420$
  7072.         addq.w    #1,d4
  7073. 421$        move.w    d4,curpos(a4)
  7074. 420$        bra    100$
  7075.  
  7076. 400$        cmp.b    #'D',1(a2)        ; cursor left
  7077.         bne.s    401$
  7078.         subq.w    #1,d4
  7079.         bpl.s    421$
  7080.         bra.s    420$
  7081.  
  7082. 401$        cmp.b    #' ',1(a2)
  7083.         bne.s    402$
  7084.         cmp.b    #'@',2(a2)        ; shift right
  7085.         bne.s    403$
  7086.  
  7087. 404$        cmp.w    ibufferlen(a4),d4
  7088.         bge.s    421$
  7089.         addq.w    #1,d4
  7090.         cmp.b    #' ',0(a1,d4.w)
  7091.         bne.s    404$
  7092. 405$        cmp.w    ibufferlen(a4),d4
  7093.         bge.s    421$
  7094.         addq.w    #1,d4
  7095.         cmp.b    #' ',0(a1,d4.w)
  7096.         beq.s    405$
  7097.         bra.s    421$
  7098.  
  7099. 403$        cmp.b    #'A',2(a2)        ; shift left
  7100.         bne.s    420$
  7101. 406$        tst.w    d4
  7102.         beq.s    421$
  7103.         subq.w    #1,d4
  7104.         cmp.b    #' ',0(a1,d4.w)
  7105.         beq.s    406$
  7106. 407$        tst.w    d4
  7107.         beq.s    421$
  7108.         subq.w    #1,d4
  7109.         cmp.b    #' ',0(a1,d4.w)
  7110.         bne.s    407$
  7111.         addq.w    #1,d4
  7112.         bra.s    421$
  7113.  
  7114. 402$        cmp.b    #'A',1(a2)        ; cursor up
  7115.         bne.s    408$
  7116.         tst.w    bottomin(a4)
  7117.         bne.s    480$
  7118.         tst.w    curpos(a4)
  7119.         bne.s    480$
  7120.  
  7121.         clr.w    curpos(a4)
  7122.         clr.w    ibufferlen(a4)
  7123.         bsr    UpdateIArea
  7124.         bsr    clrcursor
  7125.         move.w    edline(a4),d3
  7126.         ext.l    d3
  7127.         tst.w    d3
  7128.         beq.s    481$
  7129.         subq.l    #1,d3
  7130.         cmp.l    firstline(a4),d3
  7131.         bge.s    481$
  7132.         move.l    d3,-(sp)
  7133.         subq.l    #1,firstline(a4)
  7134.         bsr    blastout
  7135.         move.l    (sp)+,d3
  7136. 481$        move.w    d3,edline(a4)
  7137.         bsr    getcurpos
  7138.         bsr    putcursor
  7139.         bra    intuiend
  7140. 480$        move.l    history(a4),a0
  7141.         tst.l    0(a0)
  7142.         beq.s    423$
  7143.         move.l    curhist(a4),a1
  7144.         cmp.l    a0,a1
  7145.         beq.s    409$
  7146.         move.l    4(a1),d0
  7147.         move.l    d0,curhist(a4)
  7148. 409$        move.l    a1,gothline(a4)
  7149.         bsr    copyhistory
  7150. 423$        bra    100$
  7151.  
  7152. 408$        cmp.b    #'B',1(a2)        ; cursor down
  7153.         bne    410$
  7154.         tst.w    bottomin(a4)
  7155.         bne.s    414$
  7156.         tst.w    curpos(a4)
  7157.         bne.s    414$
  7158.  
  7159.         clr.w    curpos(a4)
  7160.         clr.w    ibufferlen(a4)
  7161.         bsr    UpdateIArea
  7162.         bsr    clrcursor
  7163.         move.w    edline(a4),d3
  7164.         ext.l    d3
  7165.         move.l    numlines(a4),d4
  7166.         subq.l    #1,d4
  7167.         cmp.l    d4,d3
  7168.         beq.s    490$
  7169.         move.l    firstline(a4),d2
  7170.         add.w    rows(a4),d2
  7171.         subq.w    #1,d2
  7172.         addq.w    #1,d3
  7173.         cmp.w    d2,d3
  7174.         ble.s    490$
  7175.         move.l    d3,-(sp)
  7176.         addq.l    #1,firstline(a4)
  7177.         bsr    blastout
  7178.         move.l    (sp)+,d3
  7179. 490$        bra    481$
  7180. 414$        move.l    curhist(a4),d0
  7181.         beq.s    423$
  7182.         move.l    d0,a1
  7183.         move.l    0(a1),a1
  7184.         tst.l    0(a1)
  7185.         bne.s    411$
  7186.         clr.l    gothline(a4)
  7187.         clr.w    curpos(a4)
  7188.         clr.w    ibufferlen(a4)
  7189.         bra    423$
  7190. 411$        move.l    a1,curhist(a4)
  7191.         bra    409$
  7192.  
  7193. 410$        cmp.b    #'T',1(a2)        ; shift up
  7194.         bne.s    412$
  7195.         tst.w    hnum(a4)
  7196.         beq     423$
  7197.         move.l    history(a4),a1
  7198.         move.l    a1,curhist(a4)
  7199.         bra    409$
  7200.  
  7201. 412$        cmp.b    #'S',1(a2)        ; shift down
  7202.         bne.s    440$
  7203.         tst.w    hnum(a4)
  7204.         beq    423$
  7205.         move.l    history+8(a4),curhist(a4)
  7206.         bra.s    414$
  7207.  
  7208. 440$        cmp.b    #'0',1(a2)        ; function keys
  7209.         bmi    423$
  7210.         cmp.b    #'9',1(a2)
  7211.         bgt    423$
  7212.         lea    1(a2),a0
  7213.         bsr    getnum
  7214.         lea    fkeys(a4),a0
  7215. 441$        move.l    0(a0),a0
  7216.         tst.l    0(a0)
  7217.         beq    100$
  7218.         cmp.b    8(a0),d2
  7219.         bne.s    441$
  7220.         moveq    #0,d3
  7221.         move.w    curpos(a4),d4
  7222.         move.b    9(a0),d5
  7223.         ext.w    d5
  7224.         subq.w    #1,d5
  7225.         lea    10(a0),a0
  7226.         lea    inputbuffer(a4),a2
  7227.         lea    0(a2,d4.w),a2
  7228. 445$        move.b    (a0)+,d0
  7229.         cmp.b    #'^',d0
  7230.         bne.s    442$
  7231.         moveq    #1,d3
  7232.         bra.s    443$
  7233. 442$        cmp.b    #'_',d0
  7234.         bne.s     444$
  7235.         move.b    #' ',d0
  7236. 444$        move.b    d0,(a2)+
  7237.         addq.w    #1,d4
  7238. 443$        dbra    d5,445$
  7239.         move.w    d4,curpos(a4)
  7240.         cmp.w    ibufferlen(a4),d4
  7241.         ble.s    446$
  7242.         move.w    d4,ibufferlen(a4)
  7243. 446$        tst.w    d3
  7244.         beq    100$
  7245.         bra    got_fkey
  7246.  
  7247. 110$        moveq    #0,d3
  7248. 101$        move.w    curpos(a4),d4
  7249.         tst.w    d0
  7250.         beq    100$
  7251.         cmp.b    #13,0(a2,d3.w)        ; return
  7252.         beq    got_enter
  7253.  
  7254.         cmp.b    #27,0(a2,d3.w)        ; esc
  7255.         bne    799$
  7256.         tst.b    getanswer(a4)
  7257.         bne    100$
  7258.         clr.b    insmode(a4)
  7259.         clr.w    ibufferlen(a4)
  7260.         move.w    #200,curpos(a4)
  7261.         bsr    UpdateIArea
  7262.         clr.w    curpos(a4)
  7263.         tst.w    bottomin(a4)
  7264.         bne.s    700$
  7265.         addq.w    #1,bottomin(a4)
  7266.         bsr    getcurpos
  7267.         cmp.b    #5,timerstate(a4)
  7268.         bne.s    765$
  7269.         bsr    starttimer
  7270. 765$        bra    100$
  7271.  
  7272. 700$        move.b    timerio+8(a4),timerstate(a4)
  7273.         bsr    stoptimer
  7274.         moveq    #0,d0
  7275.         move.w    edline(a4),d0
  7276.         move.l    firstline(a4),d4
  7277.         cmp.w    d4,d0
  7278.         bmi.s    701$
  7279.         move.w    d4,d5
  7280.         add.w    rows(a4),d5
  7281.         cmp.w    d5,d0
  7282.         bmi.s    702$
  7283. 701$        move.w    rows(a4),d0
  7284.         lsr.w    #1,d0
  7285.         add.w    d4,d0
  7286. 702$        move.l    numlines(a4),d3
  7287.         subq.w    #1,d3
  7288.         cmp.w    d3,d0
  7289.         ble.s    703$
  7290.         move.w    d3,d0
  7291. 703$        move.w    d0,edline(a4)
  7292.         sub.w    d4,d0
  7293.         mulu    txheight(a4),d0
  7294.         add.w    firstpos(a4),d0        ; BarHeight+FontHeight !
  7295.         move.w    d0,cposy(a4)
  7296.         clr.w    bottomin(a4)
  7297.         tst.w    loffset(a4)
  7298.         beq.s    704$
  7299.         clr.w    loffset(a4)
  7300.         bsr    blastout
  7301. 704$        bra    100$
  7302.  
  7303. 799$        cmp.b    #8,0(a2,d3.w)        ; Backspace
  7304.         bne.s    114$
  7305.         tst.w    d4
  7306.         beq.s    179$
  7307.         bsr    delchar
  7308.         subq.w    #1,d4
  7309.         move.w    d4,curpos(a4)
  7310.         bra.s    179$
  7311.  
  7312. 114$        cmp.b    #127,0(a2,d3.w)        ; Del
  7313.         bne.s    150$
  7314. 178$        cmp.w    ibufferlen(a4),d4
  7315.         bge.s    179$
  7316.         addq.w    #1,d4
  7317.         bsr    delchar
  7318. 179$        bra    102$
  7319.  
  7320. 150$        cmp.b    #9,0(a2,d3.w)        ; Tab
  7321.         bne    197$
  7322.         move.w    oldpos(a4),d1
  7323.         lea    inputbuffer(a4),a2
  7324.         move.b    newtab(a4),oldtab(a4)
  7325.         beq.s    152$            ; previous tab
  7326.         clr.b    newtab(a4)
  7327.         move.w    cmdcomplen(a4),d0
  7328.         add.w    d1,d0
  7329.         lea    0(a2,d0.w),a0
  7330.         move.w    cmdcplen(a4),d0
  7331.         lea    0(a0,d0.w),a1
  7332. 151$        move.b    (a1)+,(a0)+        ; restore old cmdline
  7333.         bne.s    151$
  7334.         sub.w    d0,ibufferlen(a4)
  7335.         tst.w    curpos(a4)
  7336.         beq.s    155$
  7337.         move.w    ibufferlen(a4),curpos(a4)
  7338.         bra.s    155$            ; search next cmd
  7339.  
  7340. 152$        move.w    ibufferlen(a4),d0
  7341.         move.l    a2,a0
  7342.         bsr    tolower            ; ibuffer to lower case
  7343.         move.w    curpos(a4),d0
  7344.         move.w    d0,d1
  7345.         beq.s    1532$
  7346. 153$        cmp.b    #' ',-1(a2,d1.w)    ; search down
  7347.         beq.s    1531$
  7348.         subq.w    #1,d1
  7349.         bne.s    153$
  7350. 1531$        move.w    d1,d0
  7351. 1532$        cmp.b    #' ',0(a2,d0.w)        ; search up
  7352.         beq.s    154$
  7353.         addq.w    #1,d0
  7354.         cmp.w    ibufferlen(a4),d0
  7355.         bcs.s    1532$
  7356. 154$        sub.w    d1,d0
  7357.         move.w    d0,cmdcomplen(a4)    ; chars to cmp
  7358.         move.w    d1,oldpos(a4)        ; cmp pos (for next tab)
  7359.         clr.w    cmdcompnr(a4)
  7360. 155$        lea    0(a2,d1.w),a2
  7361.  
  7362. 156$        tst.b    newtab(a4)
  7363.         bne.s    169$            ; found a cmd
  7364.         move.w    cmdcompnr(a4),d0
  7365.         bsr    getcmdptr
  7366.         move.l    d0,a0
  7367.         move.l    a2,a1
  7368.         move.w    cmdcomplen(a4),d1
  7369.         subq.w    #1,d1
  7370. 157$        move.b    (a0)+,d0        ; comp cmd <-> ibuffer
  7371.         beq.s    163$
  7372.         cmp.b    (a1)+,d0
  7373.         bne.s    163$
  7374.         dbra    d1,157$
  7375.  
  7376.         moveq    #-1,d0
  7377. 158$        addq.w    #1,d0
  7378.         tst.b    0(a0,d0.w)
  7379.         bne.s    158$
  7380.         tst.w    d0
  7381.         beq.s    162$            ; nothing to copy !
  7382.         move.l    a1,a2
  7383. 159$        tst.b    (a2)+
  7384.         bne.s    159$
  7385. 160$        move.b    -(a2),0(a2,d0.w)
  7386.         cmp.l    a2,a1
  7387.         bcs.s    160$
  7388.         move.w    d0,-(sp)
  7389. 161$        move.b    -1(a0,d0.w),-1(a1,d0.w)
  7390.         subq.w    #1,d0
  7391.         bne.s    161$
  7392.         move.w    (sp)+,d0
  7393.         tst.w    curpos(a4)
  7394.         beq.s    162$            ; was zero
  7395.         add.w    d0,curpos(a4)
  7396. 162$        add.w    d0,ibufferlen(a4)
  7397.         move.w    ibufferlen(a4),oldibuflen(a4)
  7398.         move.w    d0,cmdcplen(a4)
  7399.         st    newtab(a4)
  7400.  
  7401. 163$        addq.w    #1,cmdcompnr(a4)    ; next cmd
  7402.         moveq    #cmdnum-1,d0
  7403.         sub.w    cmdcompnr(a4),d0
  7404.         bcc.s    156$            ; not ready
  7405.         clr.w    cmdcompnr(a4)
  7406.         tst.b    oldtab(a4)
  7407.         bne.s    156$            ; prev tab
  7408. 169$        bra    100$            ; end it
  7409.  
  7410. 197$        cmp.b    #3,0(a2,d3.w)        ; ctrl c
  7411.         bne.s    104$
  7412.         st    cbreak(a4)
  7413.  
  7414. 104$        tst.b    addlines(a4)
  7415.         bne    rintui
  7416.         cmp.b    #$18,0(a2,d3.w)        ; ctrl x
  7417.         bne.s    300$
  7418.         clr.w    ibufferlen(a4)
  7419.         clr.w    curpos(a4)
  7420.         bra.s    169$
  7421.  
  7422. 300$        cmp.b    #$b,0(a2,d3.w)        ; ctrl k
  7423.         bne.s    106$
  7424.         move.w    curpos(a4),ibufferlen(a4)
  7425.         bra.s    169$
  7426.  
  7427. 106$        move.w    #$100,d5        ; NumPad
  7428.         and.w    qualifier(a4),d5
  7429.         beq    105$
  7430.         move.l    firstline(a4),d5
  7431.  
  7432.         cmp.b    #'7',0(a2,d3.w)        ; 'Home'
  7433.         bne.s    200$
  7434.         moveq    #0,d5
  7435. 199$        cmp.l    firstline(a4),d5
  7436.         beq.s    196$
  7437.         move.l    d5,firstline(a4)
  7438.         bsr    blastout
  7439.         tst.w    bottomin(a4)
  7440.         bne.s    196$
  7441.         move.w    edline(a4),d0
  7442.         move.l    firstline(a4),d1
  7443.         cmp.w    d1,d0
  7444.         bmi.s    190$
  7445.         add.w    rows(a4),d1
  7446.         cmp.w    d1,d0
  7447.         bmi.s    192$
  7448. 190$        clr.w    curpos(a4)
  7449.         clr.w    ibufferlen(a4)
  7450.         move.w    rows(a4),d0
  7451.         lsr.w    #1,d0
  7452.         ext.l    d0
  7453.         add.l    firstline(a4),d0
  7454.         cmp.l    numlines(a4),d0
  7455.         bmi.s    191$
  7456.         move.l    numlines(a4),d0
  7457.         subq.w    #1,d0
  7458. 191$        move.w    d0,edline(a4)
  7459. 192$        bsr    getcurpos
  7460.         bsr    UpdateIArea
  7461. 196$        bra    100$
  7462.  
  7463. 200$        cmp.b    #'8',0(a2,d3.w)        ; 'up arrow'
  7464.         bne.s    201$
  7465.         tst.w    d5
  7466.         beq    100$
  7467.         subq.w    #1,d5
  7468. 1990$        bra.s    199$
  7469.  
  7470. 201$        cmp.b    #'9',0(a2,d3.w)        ; 'PgUp'
  7471.         bne.s    203$
  7472.         sub.w    rows(a4),d5
  7473.         bpl.s    1990$
  7474.         moveq    #0,d5
  7475.         bra.s    1990$
  7476.  
  7477. 203$        cmp.b    #'1',0(a2,d3.w)        ; 'End'
  7478.         bne.s    205$
  7479. 222$        move.l    numlines(a4),d5
  7480.         sub.w    rows(a4),d5
  7481.         bpl    199$
  7482.         moveq    #0,d5
  7483. 204$        bra    199$
  7484.  
  7485. 205$        cmp.b    #'2',0(a2,d3.w)        ; 'down arrow'
  7486.         bne.s    206$
  7487.         move.l    d5,d2
  7488.         add.w    rows(a4),d2
  7489.         cmp.l    numlines(a4),d2
  7490.         bge    100$
  7491.         addq.w    #1,d5
  7492.         bra    199$
  7493.  
  7494. 206$        cmp.b    #'3',0(a2,d3.w)        ; 'PgDn'
  7495.         bne.s    500$
  7496.         add.w    rows(a4),d5
  7497.         move.l    d5,d2
  7498.         add.w    rows(a4),d2
  7499.         cmp.l    numlines(a4),d2
  7500.         bge.s    222$
  7501.         bra    199$
  7502.  
  7503. 500$        cmp.b    #'4',0(a2,d3.w)        ; left arrow
  7504.         bne.s    501$
  7505.         tst.w    bottomin(a4)
  7506.         beq    102$
  7507.         move.w    loffset(a4),d2
  7508.         sub.w    colms(a4),d2
  7509.         bpl.s    502$
  7510.         moveq    #0,d2
  7511. 502$        move.w    d2,loffset(a4)
  7512.         bsr    blastout
  7513.         bra    100$
  7514.  
  7515. 501$        cmp.b    #'6',0(a2,d3.w)        ; right arrow
  7516.         bne.s    170$
  7517.         tst.w    bottomin(a4)
  7518.         beq.s    102$
  7519.         move.w    loffset(a4),d2
  7520.         add.w    colms(a4),d2
  7521.         bra.s    502$
  7522.  
  7523. 170$        cmp.b    #'0',0(a2,d3.w)        ; Ins
  7524.         bne.s    177$
  7525.         not.b    insmode(a4)
  7526.         bra.s    102$
  7527.  
  7528. 177$        cmp.b    #'.',0(a2,d3.w)        ; Del
  7529.         beq    178$
  7530. 105$        tst.w    bottomin(a4)
  7531.         bne.s    777$
  7532.         tst.w    curpos(a4)
  7533.         bne.s    777$
  7534.         movem.l    d0/d1,-(sp)
  7535.         move.w    edline(a4),d0
  7536.         bsr    findline
  7537.         movem.l    (sp)+,d0/d1
  7538.         tst.l    8(a5)
  7539.         beq    intuiend
  7540. 777$        move.w    curpos(a4),d5
  7541.         ext.l    d5
  7542.         moveq    #79+40,d2
  7543.         cmp.w    d2,d5
  7544.         bge.s    102$
  7545.         tst.b    insmode(a4)
  7546.         beq.s    172$
  7547.         cmp.w    ibufferlen(a4),d5
  7548.         bmi.s    171$
  7549.         bra.s    173$
  7550. 172$        sub.w    d5,d2
  7551.         lea    80+40(a1),a5
  7552.         lea    79+40(a1),a3
  7553. 103$        move.b    -(a3),-(a5)
  7554.         dbra    d2,103$
  7555. 173$        addq.w    #1,ibufferlen(a4)
  7556. 171$        move.b    0(a2,d3),0(a1,d5)
  7557.         addq.w    #1,curpos(a4)
  7558. 102$        subq.w    #1,d0
  7559.         addq.w    #1,d3
  7560.         bra    101$
  7561.  
  7562. 100$        bsr    UpdateIArea
  7563.         bra    intuiend
  7564.  
  7565. got_enter    bsr    puthist
  7566. got_fkey    bsr    stoptimer
  7567.         clr.b    insmode(a4)
  7568.         lea    dummy(a4),a1
  7569.         lea    inputbuffer(a4),a2
  7570.         move.w    ibufferlen(a4),d2
  7571.         beq.s    2$
  7572.         tst.w    bottomin(a4)
  7573.         bne.s    5$
  7574.         movem.l    a1/a2,-(sp)
  7575.         move.w    edline(a4),d0
  7576.         bsr    findline
  7577.         move.l    8(a5),d0
  7578.         bsr    gthex
  7579.         lea    hexarea(a4),a0
  7580.         lea    0(a2,d2.w),a1
  7581.         move.b    #' ',(a1)+
  7582.         move.b    #'$',(a1)+
  7583.         moveq    #8,d0
  7584.         CALL    CopyMem,sysbase(a4)
  7585.         moveq    #10,d2
  7586.         add.w    ibufferlen(a4),d2
  7587.         move.w    d2,ibufferlen(a4)
  7588.         movem.l    (sp)+,a1/a2
  7589. 5$        subq.w    #1,d2
  7590. 1$        move.b    (a2)+,(a1)+
  7591.         dbra    d2,1$
  7592. 2$        move.b    #10,(a1)+
  7593.         move.w    ibufferlen(a4),d0
  7594.         addq.w    #1,d0
  7595.         move.w    d0,-(sp)
  7596.         clr.w    ibufferlen(a4)
  7597.         tst.w    bottomin(a4)
  7598.         bne.s    4$
  7599.         move.w    #100,curpos(a4)
  7600.         bsr    UpdateIArea
  7601. 4$        clr.w    curpos(a4)
  7602.         move.w    #1,bottomin(a4)
  7603.         bsr    getcurpos
  7604.         bsr    UpdateIArea
  7605.         move.w    (sp)+,d0        ; needed for cli
  7606.         move.w    d0,repeatlen(a4)
  7607.         clr.b    repeat(a4)
  7608.         clr.b    printed(a4)
  7609.         tst.b    getanswer(a4)
  7610.         bne.s    rintui
  7611. 6$        bsr    cli
  7612.         tst.b    printed(a4)
  7613.         bne.s    intuiend
  7614.         bsr    starttimer
  7615. intuiend    bsr.s    replyintui
  7616.         move.w    ibufferlen(a4),d0
  7617.         cmp.w    oldibuflen(a4),d0
  7618.         beq.s    1$            ; nothing changed
  7619.         clr.b    newtab(a4)
  7620. 1$        bra    nextimsg
  7621.  
  7622. processnxtmsg    tst.b    addlines(a4)
  7623.         bne.s    rintui
  7624.         tst.b    propupdate(a4)
  7625.         beq.s    1$
  7626.         clr.b    propupdate(a4)
  7627.         tst.b    propgadon(a4)
  7628.         beq.s    1$
  7629.         bsr.s    setprop
  7630. 1$        bra    processmsgs
  7631.  
  7632. replyintui    move.l    intuimsg(a4),d0
  7633.         beq.s    rintui
  7634.         move.l    d0,a1
  7635.         CALL    ReplyMsg,sysbase(a4)
  7636.         clr.l    intuimsg(a4)
  7637. rintui        rts
  7638.  
  7639. ; propgadget code
  7640. setprop        btst    #8,propinfo(a4)        ; update slider position and size
  7641.         bne.s    setprop-2
  7642.         moveq    #0,d0
  7643.         CALL    LockIBase,intuibase(a4)
  7644.         move.l    d0,a0
  7645.         move.l    wnptr(a4),a1        ; see if the user hit the
  7646.                         ; scrollbar in the meantime
  7647.         move.l    86(a1),a1        ; wn->UserPort
  7648.         lea    20(a1),a1        ; Userport->MsgList
  7649.         moveq    #$20,d1
  7650. 5$        move.l    0(a1),a1
  7651.         move.l    0(a1),d2        ; more pending messages ?
  7652.         beq.s    6$
  7653.         cmp.l    20(a1),d1        ; gadgetdown ?
  7654.         bne.s    5$
  7655.         move.l    28(a1),a2
  7656.         cmp.w    #3,38(a2)        ; scrollbar ?
  7657.         bne.s    5$
  7658.  
  7659. 6$        RECALL    UnlockIBase        ; a0=ilock
  7660.         tst.l    d2            ; used as flag (see above)!
  7661.         bne.s    4$
  7662.  
  7663. 7$        move.l    numlines(a4),d5
  7664.         moveq    #-1,d4            ; VertBody = rows*MAXBODY/numlines
  7665.         move.w    rows(a4),d3
  7666.         cmp.w    d5,d3
  7667.         bge.s    1$
  7668.         move.w    d3,d4
  7669.         mulu    #$ffff,d4
  7670.         divu    d5,d4
  7671.  
  7672. 1$
  7673. ;        moveq     #0,d2            ; VertPot = firstline*MAXPOT/(numlines-rows)
  7674.         sub.w    d3,d5
  7675.         ble.s    2$
  7676.         move.l    firstline(a4),d2
  7677.         mulu    #$ffff,d2
  7678.         divu    d5,d2
  7679.  
  7680. 2$        cmp.w    propinfo+8(a4),d4    ; did something change ?
  7681.         bne.s    3$
  7682.         cmp.w    propinfo+4(a4),d2
  7683.         beq.s    4$
  7684.  
  7685. 3$        moveq    #1|4,d0
  7686.         moveq    #0,d1
  7687.         moveq    #-1,d3
  7688.         moveq    #1,d5
  7689.         lea    sbgadget(a4),a0
  7690.         move.l    wnptr(a4),a1
  7691.         suba.l    a2,a2
  7692.         RECALL    NewModifyProp
  7693. 4$        rts
  7694.  
  7695. proppos        move.w    propinfo+4(a4),d0    ; get slider position and
  7696.         move.l    numlines(a4),d1        ; update window if necessary
  7697.         sub.w    rows(a4),d1
  7698.         ble.s    1$
  7699.         moveq    #0,d3            ; firstline=VertPot/(MAXPOT/numlines-rows)
  7700.         not.w    d3
  7701.         divu    d1,d3
  7702.         divu    d3,d0
  7703.         ext.l    d0
  7704.         cmp.l    firstline(a4),d0
  7705.         beq.s    1$
  7706.         move.l    d0,firstline(a4)
  7707.         bsr    blastout        ; update screem
  7708. 1$        rts
  7709.  
  7710. ;put an input line into the history buffer
  7711. puthist        move.w    ibufferlen(a4),d5
  7712.         move.l    d5,d0
  7713.         cmp.w    minnumchars(a4),d0
  7714.         bcs.s    1$
  7715.         move.l    gothline(a4),d1
  7716.         beq.s    5$
  7717.         move.l    d1,a2
  7718.         cmp.w    8(a2),d5
  7719.         bne.s    5$
  7720.         lea    10(a2),a2
  7721.         lea    inputbuffer(a4),a1
  7722.         subq.w    #1,d0
  7723. 6$        cmp.b    (a2)+,(a1)+
  7724.         bne.s    5$
  7725.         dbra    d0,6$
  7726.         move.l  gothline(a4),curhist(a4)
  7727.         bra.s    1$
  7728.  
  7729. 5$        moveq    #10,d0
  7730.         add.w    d5,d0
  7731.         ext.l    d0
  7732.         moveq    #1,d1
  7733.         swap    d1            ; MEMF_CLEAR
  7734.         CALL    AllocMem,sysbase(a4)
  7735.         move.l    d0,a0
  7736.         move.l    a0,d0
  7737.         beq.s    1$
  7738.         move.w    d5,8(a0)
  7739.         lea    10(a0),a2
  7740.         subq.w    #1,d5
  7741.         lea    inputbuffer(a4),a1
  7742. 2$        move.b    (a1)+,(a2)+
  7743.         dbra    d5,2$
  7744.         move.w    hnum(a4),d5
  7745.         cmp.w    maxhlines(a4),d5
  7746.         bmi.s    3$
  7747.         bsr    remhistline
  7748.         bra.s    4$
  7749. 3$        addq.w    #1,d5
  7750.         move.w    d5,hnum(a4)
  7751. 4$        move.l    d0,a1
  7752.         lea    history(a4),a0
  7753.         move.l    a1,curhist(a4)
  7754.         CALL    AddTail,sysbase(a4)
  7755. 1$        clr.l    gothline(a4)
  7756.         rts
  7757.  
  7758. ;copy a history line into the input buffer
  7759. copyhistory    lea    inputbuffer(a4),a0
  7760.         move.w    8(a1),d3
  7761.         ext.l    d3
  7762.         move.w    d3,curpos(a4)
  7763.         move.w    d3,ibufferlen(a4)
  7764.         subq.w    #1,d3
  7765.         lea    10(a1),a1
  7766. 1$        move.b    (a1)+,(a0)+
  7767.         dbra    d3,1$
  7768.         rts
  7769.  
  7770. ;remove one line from the history buffer (preserve d0!)
  7771. remhistline    move.l    d0,-(sp)
  7772.         lea     history(a4),a0
  7773.         CALL    RemHead,sysbase(a4)
  7774.         move.l    d0,a1
  7775.         move.l    a1,d0
  7776.         beq.s    1$
  7777.         moveq    #10,d0
  7778.         add.w    8(a1),d0
  7779.         RECALL    FreeMem
  7780. 1$        move.l    (sp)+,d0
  7781.         rts
  7782.  
  7783. ;kill all history lines
  7784. killhistory    bsr.s    remhistline
  7785.         move.l    history(a4),a0
  7786.         tst.l    0(a0)
  7787.         bne.s    killhistory
  7788. 2$        clr.w    hnum(a4)
  7789.         clr.l    curhist(a4)
  7790.         rts
  7791.  
  7792. ;delete one char from the input line
  7793. delchar        lea    inputbuffer(a4),a3
  7794.         lea     0(a3,d4.w),a3
  7795.         lea     -1(a3),a5
  7796.         move.w    d4,d5
  7797. 1$        cmp.w    #78+40,d5
  7798.         bge.s    2$
  7799.         move.b    (a3)+,(a5)+
  7800.         addq.w    #1,d5
  7801.         bra.s    1$
  7802. 2$        subq.w    #1,ibufferlen(a4)
  7803.         rts
  7804.  
  7805. testsig        move.l    tasksigs(a4),d0
  7806.         btst    d1,d0
  7807.         rts
  7808.  
  7809. ;Update the current position of the input line
  7810. getcurpos    moveq    #0,d3
  7811.         move.w    ipos(a4),d3
  7812.         tst.w    bottomin(a4)
  7813.         bne.s    1$
  7814.         move.w    edline(a4),d3
  7815.         sub.l    firstline(a4),d3
  7816.         mulu    txheight(a4),d3
  7817.         add.w    firstpos(a4),d3        ; BarHeight+FontHeight !
  7818. 1$        move.w    d3,cposy(a4)
  7819.         rts
  7820.  
  7821. ;rebuild the window from scratch
  7822. setupscreen    move.l    rastport(a4),a1
  7823.         moveq    #0,d0
  7824.         CALL    SetRast,gfxbase(a4)
  7825.         move.l    intuibase(a4),a6
  7826.         moveq    #1,d0
  7827.         bsr    setnewprop        ; does a RefreshWindowFrame()
  7828.         bsr    getwindowsize
  7829.         tst.w    bottomin(a4)
  7830.         bne.s    1$
  7831.         move.w    edline(a4),d0
  7832.         move.l    firstline(a4),d1
  7833.         move.w    rows(a4),d2
  7834.         move.w    d2,d4
  7835.         move.w    numlines(a4),d3
  7836.         add.w    d1,d2
  7837.         cmp.w    d2,d0
  7838.         bmi.s    2$
  7839.         lsr.w    #1,d4
  7840.         sub.w    d4,d0
  7841.         ext.l    d0
  7842.         move.l    d0,firstline(a4)
  7843. 2$        bsr    tstfirstlin
  7844. 1$        bsr.s    getcurpos
  7845.         bsr    putiline
  7846.         bsr    blastout
  7847.         bsr.s    UpdateIArea
  7848.         move.w    rows(a4),currenty(a4)
  7849.         rts
  7850.  
  7851. ;refresh the input area
  7852. UpdateIArea    movem.l    a2/a6,-(sp)        ; to change !
  7853.         move.l    rastport(a4),a2
  7854.         move.l    gfxbase(a4),a6
  7855.         moveq    #1,d0
  7856.         move.l    a2,a1
  7857.         RECALL    SetAPen
  7858.         moveq    #1,d0
  7859.         move.l    a2,a1
  7860.         RECALL    SetDrMd
  7861.         moveq    #2,d0
  7862.         add.b    bleft(a4),d0
  7863.         move.w    cposy(a4),d1
  7864.         move.l    a2,a1
  7865.         RECALL    Move
  7866.         lea    inputbuffer(a4),a0
  7867.         move.w    ibufferlen(a4),d0
  7868.         ext.l    d0
  7869.         move.w    colms(a4),d1
  7870.         sub.w    bottomin(a4),d1
  7871.         cmp.w    d1,d0
  7872.         bmi.s    1$
  7873.         move.w    d1,d0
  7874. 1$        move.w    d0,d2
  7875.         move.l    a2,a1
  7876.         RECALL    Text
  7877.         tst.w    bottomin(a4)
  7878.         bne.s    3$
  7879.         move.w    edline(a4),d0
  7880.         bsr    findline
  7881.         move.w    12(a5),d3
  7882.         sub.w    d2,d3
  7883.         bmi.s    3$
  7884.         move.w    colms(a4),d1
  7885.         sub.w    d2,d1
  7886.         bmi.s    2$
  7887.         cmp.w    d1,d3
  7888.         ble.s    4$
  7889.         move.w    d1,d3
  7890. 4$        move.w    d3,d0
  7891.         lea    14(a5,d2.w),a0
  7892.         move.l    a2,a1
  7893.         RECALL    Text
  7894.         add.w    ibufferlen(a4),d3
  7895.         move.w    d3,d2
  7896. 3$        move.w    colms(a4),d0
  7897.         sub.w    bottomin(a4),d0
  7898.         move.l    blanks(a4),a0
  7899.         ext.l    d0
  7900.         sub.w    d2,d0
  7901.         bmi.s    2$
  7902.         lea    0(a0,d2.w),a0
  7903.         move.l    a2,a1
  7904.         RECALL    Text
  7905. 2$        bsr.s    putcursor
  7906.         movem.l    (sp)+,a2/a6
  7907.         rts
  7908.  
  7909. clrcursor    moveq    #1,d7
  7910.         bra.s    ptc1
  7911. putcursor    moveq    #1+2+4,d7
  7912. ptc1        move.w    colms(a4),d0
  7913.         sub.w    bottomin(a4),d0
  7914.         subq.w    #1,d0
  7915.         cmp.w    curpos(a4),d0
  7916.         bmi.s    1$
  7917.         move.l    d7,d0
  7918.         move.l    rastport(a4),a1
  7919.         CALL    SetDrMd,gfxbase(a4)
  7920.         moveq    #0,d0
  7921.         move.w    curpos(a4),d0
  7922.         mulu    txwidth(a4),d0
  7923.         moveq    #2,d1
  7924.         add.b    bleft(a4),d1
  7925.         add.w    d1,d0
  7926.         move.w    cposy(a4),d1
  7927.         move.l    rastport(a4),a1
  7928.         RECALL    Move
  7929.         moveq    #1,d0
  7930.         lea    oneblank(a4),a0
  7931.         move.l    rastport(a4),a1
  7932.         RECALL    Text
  7933. 1$        rts
  7934.  
  7935. putiline    movem.l    d2/d3/a2,-(sp)
  7936.         move.l    rastport(a4),a2
  7937.         move.l    wnptr(a4),a5
  7938.         move.l    gfxbase(a4),a6
  7939.         moveq    #1,d0
  7940.         move.l    a2,a1
  7941.         RECALL    SetDrMd
  7942.         moveq    #1,d0
  7943.         move.w    ipos(a4),d2
  7944.         sub.w    txheight(a4),d2
  7945.         moveq    #0,d3            ; counter
  7946.         tst.b    ownscreen(a4)
  7947.         bne.s    2$
  7948.         tst.b    post_V34(a4)
  7949.         beq.s    2$
  7950.         moveq    #1,d3            ; counter
  7951. 2$        move.l    a2,a1
  7952.         RECALL    SetAPen
  7953.         moveq    #0,d0
  7954.         add.b    54(a5),d0
  7955.         move.w    d2,d1
  7956.         move.l    a2,a1
  7957.         RECALL    Move
  7958.         move.w    8(a5),d0
  7959.         tst.b    post_V34(a4)
  7960.         beq.s    1$            ; to the end
  7961.         moveq    #0,d1
  7962.         move.b    56(a5),d1
  7963.         sub.w    d1,d0
  7964. 1$        move.w    d2,d1
  7965.         move.l    a2,a1
  7966.         RECALL    Draw
  7967.         subq.w    #1,d2
  7968.         moveq    #2,d0
  7969.         dbra    d3,2$
  7970.         movem.l    (sp)+,d2/d3/a2
  7971.         rts
  7972.  
  7973. readline    moveq    #'n',d0
  7974.         tst.b    fromfile(a4)
  7975.         bne.s    1$
  7976.         move.l    #31000,firstline(a4)
  7977.         bsr    blastout
  7978.         st    getanswer(a4)
  7979.         bsr    replyintui
  7980. 5$        bsr    processmsgs
  7981.         move.w    d0,d5
  7982.         bsr    replyintui
  7983.         subq.w    #1,d5
  7984.         beq.s    5$
  7985.         clr.b    getanswer(a4)
  7986.         bsr.s    RestoreOutput
  7987.         moveq    #$20,d0
  7988.         or.b    inputbuffer(a4),d0        ; lower case
  7989. 1$        rts
  7990.  
  7991. ResumeOutput    move.l    outchain(a4),d0
  7992.         move.l    d0,a1
  7993.         beq.s    2$
  7994.         move.l    numlines(a4),oldnumlines(a4)
  7995.         move.l    firstline(a4),oldfirstline(a4)
  7996. 4$        tst.l    0(a1)
  7997.         beq.s    3$
  7998.         move.l    0(a1),a1
  7999.         bra.s    4$
  8000. 3$        move.l    a1,lastprinted(a4)
  8001. 2$        move.l    a1,oldpageend(a4)
  8002.         rts
  8003.  
  8004. RestoreOutput    move.l    oldpageend(a4),d3
  8005.         beq.s    1$
  8006.         move.l    oldnumlines(a4),numlines(a4)
  8007.         move.l    oldfirstline(a4),firstline(a4)
  8008.         move.l    oldlastprinted(a4),lastprinted(a4)
  8009.         move.l    d3,a1
  8010.         move.l    0(a1),a1
  8011.         bsr    killlines
  8012.         move.l    d3,a1
  8013.         clr.l    0(a1)
  8014.         bsr.s    blastout
  8015. 1$        rts
  8016.  
  8017. ;kill the remainder of the output buffer
  8018. killlines    move.l    sysbase(a4),a6
  8019. 1$        move.l    0(a1),-(sp)
  8020.         moveq    #14,d0
  8021.         add.w    12(a1),d0
  8022.         RECALL    FreeMem
  8023.         move.l    (sp)+,d1
  8024.         move.l    d1,a1
  8025.         bne.s    1$
  8026.         rts
  8027.  
  8028. ;Kill output buffer
  8029. killpage    movem.l    d0-d7/a0-a6,-(sp)
  8030.         move.l    outchain(a4),d1
  8031.         beq.s    1$
  8032.         move.l    d1,a1
  8033.         bsr.s    killlines
  8034.         clr.l    outchain(a4)
  8035.         clr.l    lastprinted(a4)
  8036.         clr.l    numlines(a4)
  8037.         clr.w    maxllength(a4)
  8038. 1$        movem.l    (sp)+,d0-d7/a0-a6
  8039.         rts
  8040.  
  8041. ;write a portion of the output buffer to the screen
  8042. blastout    move.l    rastport(a4),a1
  8043.         moveq    #1,d0
  8044.         CALL    SetAPen,gfxbase(a4)
  8045.         move.l    rastport(a4),a1
  8046.         moveq    #1,d0
  8047.         CALL    SetDrMd,gfxbase(a4)
  8048.         moveq    #0,d7
  8049.  
  8050.         move.w    loffset(a4),d2
  8051.         beq.s    7$
  8052.         move.w    colms(a4),d4
  8053.         add.w    d4,d2
  8054.         move.w    maxllength(a4),d3
  8055.         cmp.w    d3,d2
  8056.         ble.s    7$
  8057.         move.w    d3,d2
  8058.         sub.w    d4,d2
  8059.         bpl.s    8$
  8060.         moveq    #0,d2
  8061. 8$        move.w    d2,loffset(a4)
  8062.  
  8063. 7$        bsr.s    tstfirstlin
  8064.  
  8065. 1$        tst.l    outchain(a4)
  8066.         beq.s    3$
  8067.         bsr.s    findline
  8068.  
  8069. 2$        move.w    colms(a4),d5
  8070.         ext.l    d5
  8071.         move.w    loffset(a4),d4
  8072.         ext.l    d4
  8073.         move.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8074.  
  8075. 6$        lea    14(a5,d4.w),a0
  8076.         move.w    12(a5),d3
  8077.         ext.l    d3
  8078.         bsr.s    blastline
  8079.         blt.s    9$
  8080.         move.w    rows(a4),currenty(a4)
  8081.         bra.s    5$
  8082. 9$        tst.l    0(a5)
  8083.         beq.s    5$
  8084.         move.l    0(a5),a5
  8085.         bra.s    6$
  8086. 5$        cmp.w    rows(a4),d7
  8087.         bcc.s    3$
  8088. 10$        moveq    #0,d3
  8089.         bsr.s    blastline
  8090.         bcs.s    10$
  8091. 3$        st    propupdate(a4)
  8092.         rts
  8093.  
  8094. ;get a pointer to a line  (line # in d0)
  8095. findline    move.l    outchain(a4),d1
  8096.         beq.s    2$
  8097.         move.l    d1,a5
  8098. 1$        tst.w    d0
  8099.         beq.s    2$
  8100.         tst.l    0(a5)
  8101.         beq.s    2$
  8102.         move.l    0(a5),a5
  8103.         dbra    d0,1$
  8104. 2$        rts
  8105.  
  8106. ;check if the display is as 'full' as possible
  8107. tstfirstlin    move.l    firstline(a4),d0
  8108.         move.l    d0,d2
  8109.         add.w    rows(a4),d2
  8110.         cmp.l    numlines(a4),d2
  8111.         bmi.s    1$
  8112.         move.l    numlines(a4),d2
  8113.         sub.w    rows(a4),d2
  8114.         bpl.s    4$
  8115.         moveq    #0,d2
  8116. 4$        move.l    d2,d0
  8117.         move.l    d2,firstline(a4)
  8118. 1$        rts
  8119.  
  8120. ;display one line, fill the gap between the end of the line and
  8121. ;the end of the window with spaces.
  8122. ;d6=ypos, d5=colms, d3=linelength, d7=line # in window, a0=text
  8123.  
  8124. blastline    move.l    gfxbase(a4),a6
  8125.         moveq    #2,d0
  8126.         add.b    bleft(a4),d0
  8127.         move.w    d6,d1
  8128.         move.l    rastport(a4),a1
  8129.         RECALL    Move
  8130.         sub.w    d4,d3
  8131.         bpl.s    7$
  8132.         moveq    #0,d3
  8133.         bra.s    6$
  8134. 7$        cmp.w    d5,d3
  8135.         bmi.s    4$
  8136.         move.w    d5,d3
  8137. 4$        move.l    d3,d0
  8138.         beq.s    6$
  8139.         move.l    rastport(a4),a1
  8140.         RECALL    Text
  8141. 6$        move.l    d5,d0
  8142.         sub.l    d3,d0
  8143.         ble.s    5$
  8144.         move.l    blanks(a4),a0
  8145.         move.l    rastport(a4),a1
  8146.         RECALL    Text
  8147. 5$        add.w    txheight(a4),d6
  8148.         addq.w    #1,d7
  8149.         cmp.w    rows(a4),d7
  8150.         rts
  8151.  
  8152. addline        movem.l    d0-d6/a0-a3,-(sp)
  8153.         move.l    gfxbase(a4),a6
  8154.         move.l    rastport(a4),a1
  8155.         moveq    #1,d0
  8156.         RECALL    SetAPen
  8157.         move.l    rastport(a4),a1
  8158.         moveq    #1,d0
  8159.         RECALL    SetDrMd
  8160.         move.w    currenty(a4),d6
  8161.         cmp.w    rows(a4),d6
  8162.         bmi.s    1$
  8163.         bsr.s    cls
  8164. 1$        moveq    #0,d7
  8165.         move.w    currenty(a4),d7
  8166.         move.l    d7,d6
  8167.         mulu    txheight(a4),d6
  8168.         add.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8169.         move.w    colms(a4),d5
  8170.         moveq    #0,d4
  8171.         move.l    lastprinted(a4),a0
  8172.         move.w    12(a0),d3
  8173.         lea    14(a0),a0
  8174.         bsr    blastline
  8175.         addq.w    #1,currenty(a4)
  8176.         move.l    #31000,firstline(a4)
  8177.         movem.l    (sp)+,d0-d6/a0-a3
  8178.         rts
  8179.  
  8180. cls        movem.l d0-d6/a0-a3,-(sp)
  8181.         move.l    gfxbase(a4),a6
  8182.         moveq    #1,d0
  8183.         move.l    rastport(a4),a1
  8184.         RECALL    SetAPen
  8185.         moveq    #1,d0
  8186.         move.l    rastport(a4),a1
  8187.         RECALL    SetDrMd
  8188.         move.w    colms(a4),d5
  8189.         moveq    #0,d2
  8190. 1$        move.w    d5,d7
  8191.         move.l    d2,d6
  8192.         mulu    txheight(a4),d6
  8193.         add.w    firstpos(a4),d6        ; BarHeight+FontHeight !
  8194.         moveq    #0,d3
  8195.         move.l    blanks(a4),a0
  8196.         bsr    blastline
  8197.         addq.w    #1,d2
  8198.         cmp.w    rows(a4),d2
  8199.         bcs.s    1$
  8200.         clr.w    currenty(a4)
  8201.         movem.l    (sp)+,d0-d6/a0-a3
  8202.         rts
  8203.  
  8204. createscreen    lea    buffer(a4),a2
  8205.         moveq    #80,d0
  8206.         moveq    #1,d1
  8207.         move.l    a2,a0
  8208.         sub.l    a1,a1
  8209.         RECALL    GetScreenData
  8210.         move.w    12(a2),newscreen+4(a4)    ; width
  8211.         move.w    76(a2),newscreen+12(a4)    ; viewmode
  8212.         tst.b    post_V34(a4)
  8213.         beq.s    1$
  8214.         suba.l    a0,a0            ; examine default pubscreen
  8215.         RECALL    LockPubScreen
  8216.         move.l    d0,a2
  8217.         move.l    a2,d0
  8218.         beq.s    1$
  8219.         move.l    a6,-(sp)
  8220.         lea    44(a2),a0
  8221.         CALL    GetVPModeID,gfxbase(a4)    ; for DisplayID !
  8222.         move.l    (sp)+,a6
  8223.         move.l    d0,nsdisplay+4(a4)
  8224.         suba.l    a0,a0
  8225.         move.l    a2,a1
  8226.         RECALL    UnlockPubScreen
  8227. 1$        lea    newscreen(a4),a0    ; Kick 2.0+ with ens_Extension
  8228.         RECALL    OpenScreen
  8229.         move.l    d0,screenptr(a4)
  8230.         move.l    d0,nwscreen(a4)
  8231.         beq.s    setupwindow
  8232.         move.l    d0,a0
  8233.         clr.l    newwindow(a4)
  8234.         move.l    12(a0),newwindow+4(a4)    ; width+height
  8235.         move.w    #$474,nwflgs+2(a4)    ; IDCMP
  8236.         move.l    #$11940,nwflgs+4(a4)    ; Flags
  8237.         move.w    #$f,nwtype(a4)
  8238.         st    ownscreen(a4)
  8239.         tst.b    post_V34(a4)
  8240.         beq.s    setupwindow
  8241.         moveq    #0,d0
  8242.         RECALL    PubScreenStatus        ; make screen public
  8243.  
  8244. setupwindow    tst.b    ownscreen(a4)
  8245.         bne.s    3$            ; don't setup wb window values
  8246.         move.l    window_l(a4),newwindow(a4)
  8247.         move.l    window_w(a4),newwindow+4(a4)
  8248.         move.w    #$676,nwflgs+2(a4)    ; IDCMP
  8249.         move.l    #$5104f,nwflgs+4(a4)    ; $40000 - WFLG_NW_EXTENDED
  8250.         move.w    #1,nwtype(a4)
  8251. 3$        lea    newwindow(a4),a0
  8252.         RECALL    OpenWindow        ; Kick 2.0+ with enw_Extension
  8253.         move.l    d0,wnptr(a4)
  8254.         beq    stopall            ; no window !!!
  8255.         move.l    d0,a0
  8256.         move.l    50(a0),rastport(a4)    ; wn->RPort
  8257.         move.l    86(a0),a1        ; wn->UserPort
  8258.         moveq    #0,d1
  8259.         move.b    15(a1),d1        ; MsgPort->SigBit
  8260.         move.w    d1,intuisig(a4)
  8261.  
  8262.         tst.b    ownscreen(a4)
  8263.         bne.s    2$
  8264.         tst.b    iconifyon(a4)
  8265.         beq.s    2$
  8266.         tst.b    post_V34(a4)
  8267.         bne.s    2$
  8268.         lea    iconifgad(a4),a1    ; a0 - still wnptr !
  8269.         moveq    #0,d0
  8270.         RECALL    AddGadget
  8271.  
  8272. 2$        bsr    setwintitle
  8273.         bsr    setreqfont        ; set requested font
  8274.         moveq    #0,d0
  8275.         bsr.s    setnewprop
  8276.  
  8277.         move.l    wnptr(a4),a0
  8278.         move.l    46(a0),a0        ; our scr ptr
  8279.         cmp.l    60(a6),a0        ; ib_FirstScreen
  8280.         beq.s    1$            ; our screen is frontmost
  8281.         RECALL    ScreenToFront
  8282.  
  8283. 1$        bsr    getcurpos
  8284.         bsr    putiline
  8285.         bsr    UpdateIArea
  8286.         bsr    starttimer
  8287.         bsr    showwhat
  8288.         rts
  8289.  
  8290. setnewprop    tst.b    propgadon(a4)        ; resize propgadget !
  8291.         beq.s    1$
  8292.         move.l    wnptr(a4),a0
  8293.         lea    sbgadget(a4),a1
  8294.         tst.w    d0
  8295.         beq.s    3$            ; no gadget !
  8296.         movem.l    a0/a1,-(sp)
  8297.         RECALL    RemoveGadget        ; remove gadget from window
  8298.         movem.l    (sp)+,a0/a1
  8299. 3$        move.w    txheight(a4),d0
  8300.         move.w    firstpos(a4),d1 
  8301.         sub.w    d0,d1            ; barheight:=firstpos-txheight
  8302.         addq.w    #1,d1
  8303.         move.w    d1,6(a1)        ; topedge
  8304.         add.w    d0,d1
  8305.         lsr.w    #1,d0
  8306.         add.b    57(a0),d0
  8307.         add.w    d0,d1            ; +FontHeight*1.5
  8308.         neg.w    d1
  8309.         move.w    d1,10(a1)        ; height
  8310.         moveq    #14,d1
  8311.         move.b    56(a0),d0
  8312.         beq.s    2$            ; use default value
  8313.         move.b    d0,d1
  8314. 2$        subq.w    #2,d1
  8315.         move.w    d1,8(a1)        ; with
  8316.         neg.w    d1
  8317.         move.w    d1,4(a1)        ; leftedge
  8318.         moveq    #0,d0
  8319.         RECALL    AddGadget
  8320. 1$        move.l    wnptr(a4),a0
  8321.         jmp    _LVORefreshWindowFrame(a6)
  8322.  
  8323. setreqfont    move.l    a6,-(sp)
  8324.         move.l    gfxbase(a4),a6
  8325.         tst.b    topaz(a4)        ; use 'old' system font ?
  8326.         beq.s    3$
  8327.         move.l    topazfont(a4),d0    ; already open ?
  8328.         bne.s    2$
  8329.         lea    tattr(a4),a0        ; try topaz/8
  8330.         RECALL    OpenFont
  8331.         move.l    d0,topazfont(a4)    ; got ?
  8332.         bne.s    2$
  8333. 3$        move.l    ownfont(a4),d0        ; own 'my' font ?
  8334.         bne.s    2$
  8335.         move.l    154(a6),d0        ; GfxBase->DefaultFont
  8336. 2$        move.l    d0,a0
  8337.         move.l    rastport(a4),a1
  8338.         RECALL    SetFont
  8339.         move.l    wnptr(a4),a0
  8340.         move.l    46(a0),a1        ; Window->Screen
  8341.         move.b    30(a1),d1        ; Screen->BarHeight
  8342.         ext.w    d1
  8343.         move.b    54(a0),bleft(a4)
  8344.         move.l    50(a0),a1        ; Window->RastPort
  8345.         move.w    58(a1),txheight(a4)
  8346.         move.w    60(a1),txwidth(a4)
  8347.         add.w    txheight(a4),d1
  8348.         move.w    d1,firstpos(a4)
  8349.         bsr.s    getwindowsize
  8350. 1$        move.l    (sp)+,a6
  8351.         rts
  8352.  
  8353. getwindowsize    bsr.s    freeblank
  8354.  
  8355.         move.l    wnptr(a4),a0
  8356.  
  8357.         move.w    txheight(a4),d0
  8358.         lsr.w    #1,d0            ; FontHeight*0.5
  8359.         add.b    57(a0),d0
  8360.         neg.w    d0
  8361.         add.w    10(a0),d0
  8362.         move.w    d0,ipos(a4)        ; input area position
  8363.  
  8364.         moveq    #0,d6
  8365.         move.w    txheight(a4),d6
  8366.         lsr.w    #1,d6
  8367.         add.w    firstpos(a4),d6
  8368.         neg.w    d6
  8369.         add.w    d0,d6            ; rows=(ipos-firstpos-0.5*txheight)/txheight
  8370.         divu    txheight(a4),d6
  8371.         move.w    d6,rows(a4)
  8372.  
  8373.         moveq    #0,d6
  8374.         move.b    54(a0),d6
  8375.         add.b    56(a0),d6
  8376.         bne.s    3$
  8377.         tst.b    propgadon(a4)
  8378.         beq.s    3$
  8379.         move.w    sbgadget+8(a4),d6
  8380. 3$        addq.w    #4,d6
  8381.         neg.w    d6
  8382.         add.w    8(a0),d6
  8383.         divu    txwidth(a4),d6        ; colms=(width-lborder-rborder)/txwidth
  8384.         move.w    d6,colms(a4)
  8385.  
  8386.         moveq    #0,d0
  8387.         move.w    d6,d0
  8388.         moveq    #0,d1
  8389.         CALL    AllocMem,sysbase(a4)
  8390.         move.l    d0,blanks(a4)
  8391.         move.l    d0,a0
  8392.         moveq    #' ',d0
  8393.         bra.s    1$
  8394. 2$        move.b    d0,(a0)+
  8395. 1$        dbra    d6,2$
  8396.         rts
  8397.  
  8398. freeblank    move.l    blanks(a4),d0
  8399.         beq.s    1$
  8400.         move.l    d0,a1
  8401.         moveq    #0,d0
  8402.         move.w    colms(a4),d0
  8403.         CALL    FreeMem,sysbase(a4)
  8404.         clr.l    blanks(a4)
  8405. 1$        rts
  8406.  
  8407. setwintitle    lea    winkeybuf(a4),a3    ; show hotkey in window title
  8408.         lea    defhotkey(a4),a2
  8409.         move.l    broker(a4),d0
  8410.         beq.s    2$            ; no commodity !
  8411.         move.l    d0,a0
  8412.         moveq    #0,d0
  8413.         tst.b    cxstate(a4)
  8414.         beq.s    4$            ; commodity off
  8415.         moveq    #1,d0
  8416.         lea    hotkeybuf(a4),a2
  8417. 4$        CALL    ActivateCxObj,cxbase(a4)
  8418. 3$        move.l    (a2),d1
  8419.         and.l    #$dfdfdfdf,d1
  8420.         cmp.l    #'RAWK',d1
  8421.         bne.s    2$            ; not rawkey as ieclass
  8422.         addq.w    #7,a2            ; skip ieclass (hopefully)
  8423. 2$        move.l    a2,-(sp)
  8424.         pea    copyright(a4)
  8425.         pea    verstring(a4)
  8426.         move.l    sp,a1
  8427.         lea    namefmt(a4),a0
  8428.         lea    sc_put(pc),a2
  8429.         CALL    RawDoFmt,sysbase(a4)    ; fill buffer
  8430.         lea    12(sp),sp
  8431.         move.l    wnptr(a4),a0
  8432.         move.l    a3,a1
  8433.         movea.w    #-1,a2
  8434.         tst.b    ownscreen(a4)
  8435.         beq.s    1$            ; don't change scr title
  8436.         suba.l    a1,a1
  8437.         move.l    a3,a2
  8438. 1$        move.l    intuibase(a4),a6
  8439.         jmp    _LVOSetWindowTitles(a6)    ; leave with intuibase in a6 !
  8440.  
  8441. sc_put        move.b    d0,(a3)+        ; for RawDoFmt()
  8442.         rts
  8443.  
  8444. usetopaz    lea    topaz(a4),a2
  8445.         bsr    onoff
  8446. usetopaz2    tst.b    fromfile(a4)
  8447.         bne.s    usetopaz-2        ; hack !
  8448.         bsr    setreqfont
  8449.         bra    setupscreen        ; rebuild all
  8450.  
  8451. usescreen    tst.b    ownscreen(a4)
  8452.         bne.s    1$
  8453.         tst.b    fromfile(a4)
  8454.         bne.s    2$
  8455.         moveq    #0,d0
  8456.         bsr.s    CloseGUI        ; close window
  8457.         bra    createscreen
  8458. 2$        st    ownscreen(a4)
  8459. 1$        rts
  8460.  
  8461. usewindow    tst.b    ownscreen(a4)
  8462.         beq.s    1$
  8463.         tst.b    fromfile(a4)
  8464.         bne.s    2$
  8465.         st    wantwindow(a4)
  8466.         moveq    #0,d0
  8467.         bsr.s    CloseGUI        ; close window & screen
  8468.         beq.s    1$            ; pubscreen still used
  8469.         clr.b    wantwindow(a4)
  8470. 2$        clr.b    ownscreen(a4)
  8471.         tst.b    fromfile(a4)
  8472.         bne.s    1$
  8473.         bsr    setupwindow        ; open our window
  8474. 1$        rts
  8475.  
  8476. CloseGUI    move.l    d0,d2
  8477.         bsr    replyintui        ; answer msg
  8478.         move.l    intuibase(a4),a6
  8479.         tst.b    ownscreen(a4)
  8480.         beq.s    8$
  8481.         bsr.s    SetPubStatus
  8482.         beq.s    1$            ; pubscreen still used
  8483. 8$        move.l    wnptr(a4),d0
  8484.         beq.s    6$
  8485.         move.l    d0,a0
  8486.         tst.b    ownscreen(a4)
  8487.         bne.s    7$
  8488.         move.l    4(a0),window_l(a4)
  8489.         move.l    8(a0),window_w(a4)
  8490. 7$        RECALL    CloseWindow
  8491.         clr.l    wnptr(a4)
  8492. 6$        move.l    screenptr(a4),d0
  8493.         beq.s    5$
  8494.         move.l    d0,a0
  8495.         RECALL    CloseScreen
  8496.         clr.l    screenptr(a4)
  8497. 5$        move.l    d2,d0
  8498.         beq.s    2$            ; don't close fonts
  8499.         move.l    ownfont(a4),a1
  8500.         bsr.s    3$            ; close font
  8501.         move.l    topazfont(a4),a1
  8502. 3$        move.l    a1,d1
  8503.         beq.s    2$            ; oops, no font
  8504.         move.l    a6,-(sp)
  8505.         CALL    CloseFont,gfxbase(a4)
  8506.         move.l    (sp)+,a6
  8507. 2$        moveq    #1,d0
  8508. 1$        rts
  8509.  
  8510. SetPubStatus    moveq    #1,d0
  8511.         tst.b    post_V34(a4)        ; no Kick 2.0+
  8512.         beq.s    1$
  8513.         move.l    screenptr(a4),d1
  8514.         beq.s    1$
  8515.         move.l    d1,a0            ; d0 - already one !!!
  8516.         move.l    intuibase(a4),a6
  8517.         RECALL    PubScreenStatus        ; make screen private
  8518.         tst.l    d0
  8519.         bne.s    1$
  8520.         tst.b    waitexit(a4)
  8521.         beq.s    1$            ; don't wait
  8522.         moveq    #0,d0
  8523.         move.w    nspubsig+6(a4),d1
  8524.         bset    d1,d0
  8525.         CALL    Wait,sysbase(a4)    ; wait until last win closed
  8526.         bra.s    SetPubStatus
  8527. 1$        tst.l    d0
  8528.         rts
  8529.  
  8530. ; support functions
  8531.  
  8532. CreatePort    movem.l    d2-d4/a2/a3/a6,-(sp)
  8533.         suba.l    a2,a2
  8534.         move.l    d0,d2            ; port-pri
  8535.         move.l    a0,d3            ; portname
  8536.         moveq    #-1,d0
  8537.         CALL    AllocSignal,sysbase(a4)
  8538.         moveq    #0,d4
  8539.         move.b    d0,d4
  8540.         blt.s    1$
  8541.         moveq    #34,d0
  8542.         move.l    pubclr(a4),d1        ; MEMF_CLEAR|MEMF_PUBLIC
  8543.         RECALL    AllocMem
  8544.         movea.l    d0,a2
  8545.         move.l    a2,d0
  8546.         bne.s    2$
  8547.         move.l    d4,d0
  8548.         RECALL    FreeSignal
  8549.         bra.s    1$
  8550. 2$        lea    8(a2),a3
  8551.         move.b    #4,(a3)+        ; mp_Node.ln_Type=NT_MSGPORT
  8552.         move.b    d2,(a3)+        ; mp_Node.ln_Pri
  8553.         move.l    d3,(a3)+        ; mp_Node.ln_Name
  8554.         move.w    d4,(a3)+        ; mp_Flags && mp_SigBit
  8555.         move.l    mytask(a4),(a3)+    ; mp_SigTask
  8556.         move.l    a3,8(a3)        ; mp_MsgList.Node.ln_Pred
  8557.         addq.w    #4,a3
  8558.         move.l    a3,-(a3)        ; mp_MsgList.Node.ln_Head
  8559.         tst.l    d3
  8560.         beq.s    1$
  8561.         movea.l    a2,a1
  8562.         RECALL    AddPort
  8563. 1$        move.l    a2,d0            ; MsgPort
  8564.         movem.l    (sp)+,d2-d4/a2/a3/a6
  8565.         rts
  8566.  
  8567. DeletePort    move.l    a2,-(sp)
  8568.         move.l    sysbase(a4),a6
  8569.         movea.l    d0,a2            ; port
  8570.         tst.l    10(a2)
  8571.         beq.s    1$
  8572.         movea.l    a2,a1
  8573.         RECALL    RemPort
  8574. 1$        moveq    #-1,d0            ; Port unbrauchbar
  8575.         move.b    d0,8(a2)        ; machen
  8576.         move.l    d0,20(a2)
  8577.         moveq    #0,d0
  8578.         move.b    15(a2),d0
  8579.         RECALL    FreeSignal
  8580.         movea.l    a2,a1
  8581.         moveq    #34,d0
  8582.         RECALL    FreeMem
  8583.         move.l    (sp)+,a2
  8584.         rts
  8585.  
  8586. CreateStdIO    move.l    d2,-(sp)
  8587.         move.l    d0,d2            ; reply-port
  8588.         beq.s    1$
  8589.         moveq    #48,d0
  8590.         move.l    pubclr(a4),d1        ; MEMF_CLEAR|MEMF_PUBLIC
  8591.         CALL    AllocMem,sysbase(a4)
  8592.         movea.l    d0,a0
  8593.         move.l    a0,d0
  8594.         beq.s    1$
  8595.         move.b    #5,8(a0)        ; NT_MESSAGE
  8596.         move.l    d2,14(a0)        ; ReplyPort
  8597. 1$        move.l    (sp)+,d2
  8598.         rts
  8599.  
  8600. DeleteStdIO    movea.l    d0,a1            ; io-block
  8601.         moveq    #-1,d0
  8602.         move.b    d0,8(a1)
  8603.         move.l    d0,20(a1)
  8604.         move.l    d0,24(a1)
  8605.         moveq    #48,d0
  8606.         move.l    sysbase(a4),a6
  8607.         jmp    _LVOFreeMem(a6)
  8608.  
  8609. CreateTask    movem.l    d2-d5/a2/a3/a6,-(sp)
  8610.         addq.l    #3,d0
  8611.         moveq    #-4,d2
  8612.         and.l    d0,d2            ; stack adjusted
  8613.         move.l    d1,d3            ; pri
  8614.         move.l    a0,d4            ; name
  8615.         move.l    a1,d5            ; code
  8616.         move.l    d2,-(sp)
  8617.         lea    MemList+7*4(pc),a0
  8618.         moveq    #6,d0
  8619. 3$        move.l    -(a0),-(sp)        ; copy memlist
  8620.         dbra    d0,3$
  8621.         move.l    sp,a0
  8622.         CALL    AllocEntry,sysbase(a4)    ; alloc memory
  8623.         movea.l    d0,a2
  8624.         move.l    a2,d0
  8625.         lea    8*4(sp),sp
  8626.         blt.s    2$            ; no mem !
  8627.         move.l    16(a2),a3
  8628.         move.b    #1,8(a3)        ; ln_Type
  8629.         move.b    d3,9(a3)        ; ln_Pri
  8630.         move.l    d4,10(a3)        ; ln_Name
  8631.         move.l    24(a2),d0
  8632.         add.l    d0,d2
  8633.         move.l    d2,54(a3)        ; tc_SPReg
  8634.         move.l    d0,58(a3)        ; tc_SPLower
  8635.         move.l    d2,62(a3)        ; tc_SPUpper
  8636.         lea    74(a3),a0        ; tc_MemList
  8637.         move.l    a0,8(a0)
  8638.         addq.w    #4,a0
  8639.         move.l    a0,-(a0)
  8640.         move.l    a2,a1
  8641.         RECALL    AddHead            ; store memlist
  8642.         move.l    a3,a1
  8643.         move.l    a1,d3
  8644.         exg.l    d5,a2
  8645.         suba.l    a3,a3
  8646.         RECALL    AddTask            ; start task
  8647.         cmp.w    #37,20(a6)
  8648.         bcs.s    1$            ; kick 2.0+ ?
  8649.         tst.l    d0
  8650.         bne.s    1$            ; task created
  8651.         move.l    d5,a0
  8652.         RECALL    FreeEntry        ; free memory
  8653. 2$        moveq    #0,d3
  8654. 1$        move.l    d3,d0            ; task
  8655.         movem.l    (sp)+,d2-d5/a2/a3/a6
  8656.         rts
  8657.  
  8658.         cnop    0,4
  8659.  
  8660. MemList        dc.l    0,0            ; Succ,Pred
  8661.         dc.b    0,0            ; Pri,Type
  8662.         dc.l    0            ; Name
  8663.         dc.w    2            ; NumEntries
  8664. PubClr        dc.l    $10001            ; MemType
  8665.         dc.l    92            ; Length
  8666.         dc.l    $10000            ; MemType
  8667. ;        dc.l    0            ; Length
  8668.  
  8669. killidle    bra.s    killidle
  8670.  
  8671. ; data area
  8672.  
  8673. Detached    dc.w    1            ; flag for background process
  8674.  
  8675. StpList        dc.l    *+4            ; frozen tasks list
  8676.         dc.l    0
  8677.         dc.l    StpList
  8678.  
  8679. FKeys        dc.l    *+4            ; function keys list
  8680.         dc.l    0
  8681.         dc.l    FKeys
  8682.  
  8683. History        dc.l    *+4            ; history lines list
  8684.         dc.l    0
  8685.         dc.l    History
  8686. CurHist        dc.l    0
  8687.  
  8688. NewBroker    dc.b    5,0            ; nb_Version, pad
  8689.         dc.l    NewName            ; nb_Name
  8690.         dc.l    VerString        ; nb_Title
  8691.         dc.l    Description        ; nb_Descr
  8692.         dc.w    1+2            ; nb_Unique = NBU_UNIQUE!NBU_NOTIFY
  8693.         dc.w    4            ; nb_Flags = COF_SHOW_HIDE
  8694.         dc.b    0,0             ; nb_Pri, pad
  8695.         dc.l    0            ; nb_Port
  8696.         dc.w    0            ; nb_ReservedChannel
  8697.  
  8698. InInterrupt    dc.l    0            ; ln_Succ
  8699.         dc.l    0            ; ln_Pred
  8700.         dc.b    2            ; ln_Type
  8701.         dc.b    60            ; ln_Pri
  8702.         dc.l    XopSleep        ; ln_Name
  8703.         dc.l    0            ; is_Data
  8704.         dc.l    keyhandler        ; is_Code()
  8705.  
  8706. IoCounter    dc.l    0            ; ln_Succ
  8707.         dc.l    0            ; ln_Pred
  8708.         dc.b    2            ; ln_Type
  8709.         dc.b    -1            ; ln_Pri
  8710.         dc.l    IOcntName        ; ln_Name
  8711.         dc.l    0            ; is_Data
  8712.         dc.l    countio            ; is_Code()
  8713.  
  8714. TAttr        dc.l    FontName
  8715.         dc.w    8
  8716.         dc.b    0,0
  8717.  
  8718. Window_l    dc.w    -550,1            ; initial window position
  8719. Window_w    dc.w    550,199
  8720.  
  8721. NewWindow    dc.w    0,0,0,0
  8722.         dc.b    0,1
  8723. NwFlgs        dc.l    0
  8724.         dc.l    0
  8725.         dc.l    0
  8726.         dc.l    0
  8727.         dc.l    0            ; title
  8728. NwScreen    dc.l    0
  8729.         dc.l    0
  8730.         dc.w    110,50
  8731.         dc.w    -1,-1
  8732. NwType        dc.w    0
  8733.         dc.l    NewWinTags        ; APTR enw_Extension
  8734.  
  8735. NewWinTags    dc.l    $80000090,1        ; WA_AutoAdjust,TRUE
  8736.         dc.l    0
  8737.  
  8738. NewScreen    dc.w    0,0
  8739.         dc.w    0,-1            ; ???,STDSCREENHEIGHT
  8740.         dc.w    1
  8741.         dc.b    0
  8742.         dc.b    1
  8743.         dc.w    0
  8744.         dc.w    $101f            ; $1000 - NS_EXTENDED
  8745.         dc.l    0
  8746.         dc.l    0            ; title
  8747.         dc.l    0,0
  8748.         dc.l    NewScrTags        ; APTR ens_Extension
  8749.  
  8750. NewScrTags    dc.l    $80000023,-1        ; SA_Width,STDSCREENWIDTH
  8751.         dc.l    $80000039,-1        ; SA_AutoScroll,TRUE
  8752. NsDisplay    dc.l    $80000032,0        ; SA_DisplayID
  8753. NsPubName    dc.l    $8000002f,NewName    ; SA_PubName
  8754. NsPubSig    dc.l    $80000030,0        ; SA_PubSig
  8755.          dc.l    0            ; TAG_DONE
  8756.  
  8757. IcnWindow    dc.w    40,170,72,28        ; sleep window
  8758.         dc.b    0,1
  8759.         dc.l    $20,$10800
  8760.         dc.l    Gadget,0,0,0,0
  8761.         dc.w    72,28,72,28
  8762.         dc.w    1
  8763.  
  8764. AppObj        dc.w    0,0            ; contains gadget
  8765.  
  8766. Gadget        dc.l    0
  8767.         dc.w    0,0,72,28,4,2,$20
  8768.         dc.l    Image
  8769.         dc.l    0,0,0,0
  8770.         dc.w    0
  8771.         dc.l    0
  8772.  
  8773.         dc.w    0
  8774.         dc.l    0,0
  8775.         dc.l    $80000000,$80000000
  8776.         dc.l    0,0,0
  8777.  
  8778. Image        dc.w    0,0,72,28
  8779.         dc.w    2
  8780.         dc.l    ImageData
  8781.         dc.b    3,0
  8782.         dc.l    0
  8783.  
  8784. IconifGad    dc.l    0            ; zip gadget for Kick 1.3
  8785.         dc.w    -83,0
  8786.         dc.w    31,10
  8787.         dc.w    $14,$41,1
  8788.         dc.l    IconImg
  8789.         dc.l    0,0,0,0
  8790.         dc.w    0
  8791.         dc.l    0
  8792. IconImg        dc.w    0,0,31,10
  8793.         dc.w    2
  8794.         dc.l    IconifData
  8795.         dc.b    3,0
  8796.         dc.l    0
  8797.  
  8798. SBGadget    dc.l    0            ; prop gadget
  8799.         dc.w    -14,11
  8800.         dc.w    14,-22
  8801.         dc.w    $10|$40
  8802.         dc.w    1|2|8|16
  8803.         dc.w    3
  8804.         dc.l    SBData,0,0,0,PropInfo
  8805.         dc.w    3
  8806.         dc.l    0
  8807. PropInfo    dc.w    1|4
  8808.         dc.w    0,0
  8809.         dc.w    -1,-1
  8810.         dc.w    0,0,0,0,0,0
  8811. SBData        dc.l    0,0,0,0
  8812.  
  8813. HexTab        dc.b    '0123456789abcdef'
  8814.  
  8815. Params        dc.b    'tfdlrempiscua'
  8816. parmnum        equ    *-Params
  8817. .parmnum    dc.b    0
  8818.  
  8819. cmdnum        set    0
  8820. Commds         ADDCMD    'time'            ; all commands we know
  8821.         ADDCMD    'taskpri'
  8822.         ADDCMD    'info'
  8823.         ADDCMD    'pri'
  8824.         ADDCMD    'flush'
  8825.         ADDCMD    'freeze'
  8826.         ADDCMD    'warm'
  8827.         ADDCMD    'signal'
  8828.         ADDCMD    'break'
  8829.         ADDCMD    'alert'
  8830.         ADDCMD    'lastalert'
  8831.         ADDCMD    'hold'
  8832.         ADDCMD    'exit'
  8833.         ADDCMD    'clear'
  8834.         ADDCMD    'cancel'
  8835.         ADDCMD    'taskports'
  8836.         ADDCMD    'hunks'
  8837.         ADDCMD    'devices'
  8838.         ADDCMD    'openlib'
  8839.         ADDCMD    'closelib'
  8840.         ADDCMD    'currentdir'
  8841.         ADDCMD    'cd'
  8842.         ADDCMD    'mypri'
  8843.         ADDCMD    'files'
  8844.         ADDCMD    'locks'
  8845.         ADDCMD    'unlock'
  8846.         ADDCMD    'screens'
  8847.         ADDCMD    'windows'
  8848.         ADDCMD    'closescreen'
  8849.         ADDCMD    'closewindow'
  8850.         ADDCMD    'fonts'
  8851.         ADDCMD    'windowfonts'
  8852.         ADDCMD    'lockdrive'
  8853.         ADDCMD    'freedrive'
  8854.         ADDCMD    'capture'
  8855.         ADDCMD    'clrcold'
  8856.         ADDCMD    'clrcool'
  8857.         ADDCMD    'clrwarm'
  8858.         ADDCMD    'snoopmem'
  8859.         ADDCMD    'usage'
  8860.         ADDCMD    'inputhandler'
  8861.         ADDCMD    'header'
  8862.         ADDCMD    'sort'
  8863.         ADDCMD    'hide'
  8864.         ADDCMD    'hidden'
  8865.         ADDCMD    'window'
  8866.         ADDCMD    'kill'
  8867.         ADDCMD    'iconify'
  8868.         ADDCMD    'historylines'
  8869.         ADDCMD    'minimumchars'
  8870.         ADDCMD    'showhistory'
  8871.         ADDCMD    'repeat'
  8872.         ADDCMD    'remresident'
  8873.         ADDCMD    'saveoutput'
  8874.         ADDCMD    'killhistory'
  8875.         ADDCMD    'backdropicon'
  8876.         ADDCMD    'myfont'
  8877.         ADDCMD    'setfont'
  8878.         ADDCMD    'trapguru'
  8879.         ADDCMD    'outputlines'
  8880.         ADDCMD    'usescreen'
  8881.         ADDCMD    'usewindow'
  8882.         ADDCMD    'usetopaz'
  8883.         ADDCMD    'timerio'
  8884.         ADDCMD    'diskchange'
  8885.         ADDCMD    'alias'
  8886.         ADDCMD    'remnode'
  8887.         ADDCMD    'setfkey'
  8888.         ADDCMD    'clicmd'
  8889.         ADDCMD    'taskinfo'
  8890.         ADDCMD    'coldreboot'
  8891.         ADDCMD    'reboot'
  8892.         ADDCMD    'zerotimer'
  8893.         ADDCMD    'propgad'
  8894.         ADDCMD    'iconpos'
  8895.         ADDCMD    'remport'
  8896.         ADDCMD    'remintserver'
  8897.         ADDCMD    'frags'
  8898.         ADDCMD    'traceopen'
  8899.         ADDCMD    'tracelock'
  8900.         ADDCMD    'cxhandler'
  8901.         ADDCMD    'popkey'
  8902.         ADDCMD    'pubscreens'
  8903.         ADDCMD    'smartpatch'
  8904.         ADDCMD    'lowmemhandler'
  8905.  
  8906.         IFNE    ((tasktime-cmdaddr)/4)-cmdnum
  8907.         ERROR    !! COMMAND NAME OR JUMP VECTOR MISSING !!
  8908.         ENDC
  8909.  
  8910. NewName        dc.b    'Xoper'
  8911. NoName        dc.b    0
  8912. XopCon        dc.b    'XopPackets',0
  8913. XopSleep    dc.b    'Xop-A-A-x',0
  8914. MemPortName    dc.b    'SnoopPort',0
  8915. IOcntName    dc.b    'Xop-I/O-Counter',0
  8916. KidleName    dc.b    'Xop-Idle-Killer',0
  8917. NameFmt        dc.b    '%s %s - <PopKey=%s>',0
  8918.         even                ; important for mc68000 !
  8919. DefHotkey    dc.b    'lcommand rcommand x',0
  8920.         dc.b    '$VER: '
  8921. VerString    VERSION
  8922. Copyright    dc.b    '© 1988/95 by W.Günther and G.Nikl',0
  8923. Description    dc.b    'A very powerful system monitor',0
  8924.  
  8925. T2Header    dc.b    '   ID     STATE  SIGALLOC SIGWAIT  SIGRECVD    PC    FPU  TASKNAME',0
  8926. T3Header    dc.b    '   ID     STATE  SIGALLOC SIGWAIT  SIGRECVD    PC    TASKNAME',0
  8927. T4Header    dc.b    '   ID     STATE    RUNNING    ACTIVE   NUM TASKNAME',0
  8928. THeader        dc.b    '   ID     TYPE      STATE   PRI  CPUSE NUM TASKNAME',0
  8929. LHeader        dc.b    '  NODE    CNT  VER  REV  FLAGS    ',0
  8930. LibNam        dc.b    'LIBRARY NAME',0
  8931. DevNam        dc.b    'DEVICE NAME',0
  8932. ResNam        dc.b    'RESOURCE NAME',0
  8933. MHeader        dc.b    ' LOWER    UPPER       FREE   ATTR  PRI HUNK NAME',0
  8934. IHeader        dc.b    '  NODE     DATA     CODE    PRI T S   TYPE     INTERRUPT NAME',0
  8935. InHeader    dc.b    '  NODE     DATA     CODE    PRI NAME',0
  8936. RHeader        dc.b    '  ADDR    PRI  FLAGS    VER   TYPE    RESIDENT NAME',0
  8937. PHeader        dc.b    '  NODE   PORTNAME         FLAGS SIGBT NUM SIGTASK',0
  8938. HunkHeader    dc.b    ' NUM  BCPL    DATA       LENGTH',0
  8939. DDHeader    dc.b    'DEVICE    HDS   SECTORS    TRACKS   BUFFERS STATE    HANDLER',0
  8940. CDHeader    dc.b    'PROCESSNAME          CURRENT DIRECTORY',0
  8941. OFHeader    dc.b    '  LOCK   ACCESS      SIZE PATH/FILENAME',0
  8942. ScrHeader    dc.b    'NUM   ADDR      SIZE   DPTH TITLE',0
  8943. MonitorID    dc.b    '    MonitorID: $',0
  8944. PScrHeader    dc.b    '  NODE   SCREENNAME         STATE CNT SBT SIGTASK',0
  8945. WnHeader    dc.b    ' ADDR    OWNERTASK     X    Y     SIZE    TITLE',0
  8946. FoHead        dc.b    '  NODE    CNT   Y    X  TYPE        LO  HI NAME',0
  8947. KickHead    dc.b    'START    END      LENGTH',0
  8948. SnoopHead    dc.b    'ACTION          REQUIREMENTS               LENGTH    FROM      TO     CALLER',0
  8949. StackHead    dc.b    'SPLower       SIZE      USED TASKNAME',0
  8950. CliComHead    dc.b    '   ID     STATE   TYPE MODE NUM PROCESSNAME       COMMAND',0
  8951. TioHead        dc.b    'IORQUEST  UNIT       SECS    REQUESTING TASK',0
  8952. DCHead        dc.b    '  NODE     DATA     CODE   UNIT TASK',0
  8953. ALHead        dc.b    'ALIAS NAME        COMMAND',0
  8954. SemHead        dc.b    '  NODE   OWNER         QUEUE NEST NAME',0
  8955. FragHead    dc.b    'HEX    SIZE    DEC     COUNT   LARGEST',0
  8956. FKHead        dc.b    'KEY  STRING',0
  8957. FilesHead    dc.b    '   TASK      HANDLE   MODE  FILENAME',0
  8958. TDDrives    dc.b    'DF : ',0
  8959. UnitMsg        dc.b    ' (Unit # )',0
  8960. TimerUnits    dc.b    'MicroHz ',0
  8961.         dc.b    'VBlank  ',0
  8962. FMode        dc.b    '  R/W  ',0
  8963. Access        dc.b    ' Read  ',0
  8964.         dc.b    ' Write ',0
  8965. RomFnt        dc.b    'Rom  ',0
  8966. DiskFnt        dc.b    'Disk ',0
  8967. FFixed        dc.b    'Fixed ',0
  8968. FProp        dc.b    'Propl ',0
  8969. Status        dc.b    'Added   ',0
  8970.         dc.b    'Running ',0
  8971.         dc.b    'Ready   ',0
  8972.         dc.b    'Waiting ',0
  8973.         dc.b    'Exeption',0
  8974.         dc.b    'Removed ',0
  8975.         dc.b    'Frozen  ',0
  8976.         dc.b    'Frozen  ',0
  8977. Type        dc.b    'Unknown   ',0
  8978. TaskType    dc.b    'Task      ',0
  8979.         dc.b    'Interrupt ',0
  8980.         dc.b    'Device    ',0
  8981.         dc.b    'Msgport   ',0
  8982.         dc.b    'Message   ',0
  8983.         dc.b    'Freemsg   ',0
  8984.         dc.b    'Replymsg  ',0
  8985.         dc.b    'Resource  ',0
  8986.         dc.b    'Library   ',0
  8987.         dc.b    'Memory    ',0
  8988. SoftIntType    dc.b    'Softint   ',0
  8989.         dc.b    'Font      ',0
  8990. ProcType    dc.b    'Process   ',0
  8991.         dc.b    'Semaphore ',0
  8992. Mp_Flags    dc.b    'Signal  ',0
  8993.         dc.b    'Softint ',0
  8994.         dc.b    'Ignore  ',0
  8995. PScr_State    dc.b    '  Public ',0
  8996.         dc.b    ' Private ',0
  8997. Infoh2        dc.b    'Dispat/Sec:',0
  8998. Infoh1        dc.b    'CPU:',0
  8999. Infoh3        dc.b    'CPU activity: ',0
  9000. Infoh6        dc.b    'Total:',0
  9001. Infoh4        dc.b    '% ',0
  9002. Infoh7        dc.b    'I/O Ints/Sec: ',0
  9003. CPU0        dc.b    '68000',0
  9004. CPU1        dc.b    '68010',0
  9005. CPU2        dc.b    '68020',0
  9006. CPU3        dc.b    '68030',0
  9007. CPU4        dc.b    '68040',0
  9008. CPU5        dc.b    '68060',0
  9009. FPU0        dc.b    '/68881',0
  9010. FPU1        dc.b    '/68882',0
  9011. FPU2        dc.b    '/FPU40',0
  9012. NoFPU        dc.b    '---- ',0
  9013. NullState    dc.b    'NULL ',0
  9014. Idle        dc.b    'IDLE ',0
  9015. Busy        dc.b    'BUSY ',0
  9016. DontKnow    dc.b    '???? ',0
  9017. DevLoad        dc.b    'loaded   ',0
  9018. DevnLoad    dc.b    'unloaded ',0
  9019. IntEn        dc.b    'E ',0
  9020. IntDis         dc.b    'D ',0
  9021. IntServ        dc.b    'S ',0
  9022. IntHand        dc.b    'H ',0
  9023. NotFile        dc.b    '--- --------- --------- --------- ',0
  9024. LongLongNix    dc.b    '-'
  9025. LongNix        dc.b    '-----'
  9026. Nix        dc.b    '--- ',0
  9027. NoInfo        dc.b    'No Info on'
  9028. OneBlank    dc.b    ' ',0
  9029. Equal        dc.b    '=  ',0
  9030. OpenBrak    dc.b    '[ ',0
  9031. CloseBrak    dc.b    ' ]',0
  9032. NamErr        dc.b    'Unable to find ',0
  9033. FontErr        dc.b    "Can't open ",0
  9034. AdrErr        dc.b    'Address Error!',0
  9035. AliasErr    dc.b    'Single character alias names using "',0
  9036. AliasErr2    dc.b    '"',10,'are not allowed.',0
  9037. NoWorkbench    dc.b    "Workbench isn't active !",0
  9038. OpenErr        dc.b    'Could not open file ',0
  9039. ListErr        dc.b    'Unable to find ListHeader. Sort aborted.',0
  9040. WiwErr        dc.b    'Script file only',0
  9041. GuruTxt        dc.b    'Guru Meditation #',0
  9042. ClrTxt        dc.b    'Memory Hunks cleared.',0
  9043. CanErr0        dc.b    'Process is not a CLI-task',10
  9044.         dc.b    'Has it been started from Workbench ? (Y/N)',10,0
  9045. CanErr1        dc.b    'Process was created by CreateProc()',10
  9046.         dc.b    'Shall I UnLoad() ? (Y/N)',10,0
  9047. UnloadErr    dc.b    "Arrrgh.. can't find segments, aborting",0
  9048. NoProcs        dc.b    'Not a Process.',0
  9049. NotLoad        dc.b    'No program loaded.',0
  9050. CliProcs    dc.b    'CLI-Process',0
  9051. ProcLoaded    dc.b    'Loaded as a command: ',0
  9052. SegLoaded    dc.b    'Created by CreateProc()',0
  9053. ColdTxt        dc.b    'Cold Capture: ',0
  9054. CoolTxt        dc.b    'Cool Capture: ',0
  9055. WarmTxt        dc.b    'Warm Capture: ',0
  9056. KickTxt        dc.b    'KickMem     : ',0
  9057. Unset        dc.b    'unset',0
  9058. IntNames    dc.b    'Serial Out ',0
  9059.         dc.b    'Disk Block ',0
  9060.         dc.b    'SoftInt    ',0
  9061.         dc.b    'Ports      ',0
  9062.         dc.b    'Coper      ',0
  9063.         dc.b    'Vert.Blank ',0
  9064.         dc.b    'Blitter    ',0
  9065.         dc.b    'Audio Ch.0 ',0
  9066.         dc.b    'Audio Ch.1 ',0
  9067.         dc.b    'Audio Ch.2 ',0
  9068.         dc.b    'Audio Ch.3 ',0
  9069.         dc.b    'Serial In  ',0
  9070.         dc.b    'Disk Sync  ',0
  9071.         dc.b    'External   ',0
  9072.         dc.b    'SoftInt    ',0
  9073.         dc.b    'NMI        ',0
  9074. IntTyp        dc.b    0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1
  9075. MemNoExp    dc.b    'NOEXP ',0
  9076. MemRev        dc.b    'REV ',0
  9077. MemLarg        dc.b    'LARGEST ',0
  9078. MemClr        dc.b    'CLEAR ',0
  9079. MemKick        dc.b    'KICK ',0
  9080. MemDMA        dc.b    '24BIT ',0
  9081. MemLoc        dc.b    'LOCAL ',0
  9082. MemFast        dc.b    'FAST ',0
  9083. MemChip        dc.b    'CHIP ',0
  9084. MemPubl        dc.b    'PUBLIC ',0
  9085. Failed        dc.b    'Failed !',0
  9086. AllOk        dc.b    'ALLOC: ',0
  9087. Free        dc.b    'FREE: ',0
  9088. Backg        dc.b    'Bckg ',0
  9089. Foreg        dc.b    'Frgr ',0
  9090. Script        dc.b    'Batch ',0
  9091. Interact    dc.b    'Intct ',0
  9092. NameErr        dc.b    'Name or address is missing.',10
  9093. SynErr        dc.b    'Syntax Error, type "?" for help'
  9094. CR        dc.b    10,0
  9095. Dnotf        dc.b    'Directory not found',0
  9096. NotDir        dc.b    'Not a directory',0
  9097. NoMount        dc.b    ' not mounted.',0
  9098. DisHelp        dc.b    10,'Names are case sensitive and followed by a ":"',0
  9099. UnlErr        dc.b    'Lock not found',0
  9100. Unl1        dc.b    'Lock is on ',0
  9101. UnlTxt        dc.b    'Old lock was: ',0
  9102. UnlTxt2        dc.b    'Unlock ? (Y/N)',10,0
  9103. ScNoFound    dc.b    'Screen not found.',0
  9104. WinNoFound    dc.b    'Window not found.',0
  9105. StpErr        dc.b    'Task must be "READY" or "WAITING"',10,0
  9106. WaErr        dc.b    'Task must be "FROZEN"',10,0
  9107. WhatsThis    dc.b    '???.?',0
  9108. TooMuch        dc.b    '??? ',0
  9109. TimeNotSet    dc.b    ' disabled.',0
  9110. WhatTime    dc.b    'Refresh time in secs:',0
  9111. Stopped        dc.b    '<Break>',0
  9112. CapExited    dc.b    'Task ended',0
  9113. CapWait        dc.b    'Waiting for startup...',0
  9114. OnScr        dc.b    'On Screen: ',0
  9115. WhatNow        dc.b    'Kill, ignore (K/I)?',0
  9116. NoGuru        dc.b    'None found.',0
  9117. SoftFail    dc.b    'Software failure!',10,'Task: ',0
  9118. AddrsErr    dc.b    'Bad aligned address was: ',0
  9119. ProCount    dc.b    'PC: ',0
  9120. MemTyp        dc.b    'Memory type: ',0
  9121. NintrServ    dc.b    "Not a server. Can't restore vectors",0
  9122. OnStr        dc.b    'on',0
  9123. OffStr        dc.b    'off',0
  9124. UseTxt        dc.b    'DISPLAY:',10
  9125.         dc.b    '[T]asks    task[F]lags [L]ibraries  [D]evices    [R]esources',10
  9126.         dc.b    'r[E]sident [M]emory    [P]orts      [I]nterrupts [S]tack',10
  9127.         dc.b    '[C]litasks task[U]sage sem[A]phores [Q]uit',10,10
  9128.         dc.b    'OTHER SYSTEM LISTS:',10
  9129.         dc.b    'Windows  Screens  PubScreens  WindowFonts   Fonts',10
  9130.         dc.b    'Capture  TimerIO  DiskChange  InputHandler  Devices',10
  9131.         dc.b    'Locks    Files    CurrentDir  LowMemHandler Frags',10,10
  9132.         dc.b    'COMMANDS:',10
  9133.         dc.b    'Time         <secs>',10
  9134.         dc.b    'Mypri        <priority>',10
  9135.         dc.b    'Taskpri      <priority>  [processnum] <taskname>',10
  9136.         dc.b    'Signal       <mask(hex)> [processnum] <taskname>',10
  9137.         dc.b    'Break        [processnum] <taskname>',10
  9138.         dc.b    'Freeze|Warm  [processnum] <taskname>',10
  9139.         dc.b    'Kill/Cancel  [processnum] <taskname>',10
  9140.         dc.b    'SnoopMem     [processnum] <taskname>',10
  9141.         dc.b    'TraceOpen/TraceLock',10
  9142.         dc.b    'ZeroTimer    [processnum] <taskname>',10
  9143.         dc.b    'Hide         <taskname>',10
  9144.         dc.b    'Pri          <priority> <nodename>',10
  9145.         dc.b    'Info         <name>',10
  9146.         dc.b    'RemNode      <node address>',10
  9147.         dc.b    'RemPort      <port address>',10
  9148.         dc.b    'RemResident  <resident module name>',10
  9149.         dc.b    'RemIntServer <interrupt address>',10
  9150.         dc.b    'Clear        <longword(hex)>',10
  9151.         dc.b    'Hunks        [processnum] <procname>',10
  9152.         dc.b    'CD           <directory> [processnum] <procname>',10
  9153.         dc.b    'UnLock       <lock>',10
  9154.         dc.b    'OpenLib    | Closelib <libraryname>',10
  9155.         dc.b    'CloseWindow| Closescreen <title>',10
  9156.         dc.b    'MyFont       [size] <fontname> | '
  9157. DefFont        dc.b    'default',10
  9158.         dc.b    'SetFont      [size] <fontname> <windowtitle>',10
  9159.         dc.b    'LockDrive  | Freedrive   <drivename:>',10
  9160.         dc.b    'Window       <leftedge topedge width height> (scriptfile only) ',10
  9161.         dc.b    'IconPos      <leftedge topedge>',10
  9162.         dc.b    'OutputLines  <maximum # of lines>',10
  9163.         dc.b    'HistoryLines <maximum # of lines>',10
  9164.         dc.b    'MinimumChars <minimum # of characters>',10
  9165.         dc.b    'SaveOutput   <filename>',10
  9166.         dc.b    'PopKey       <description>',10
  9167.         dc.b    'Repeat       <Command line>',10
  9168.         dc.b    'SetFKey      <number> <string>',10
  9169.         dc.b    'Alias        [<aliasname> <commandname>]',10,10
  9170.         dc.b    'COMMANDS WITHOUT PARAMETERS:',10
  9171.         dc.b    'Alert      LastAlert ClrCool       ClrCold      ClrWarm',10
  9172.         dc.b    'TrapGuru   Flush     ShowHistory   KillHistory  ColdReboot',10
  9173.         dc.b    'Reboot     Hold      Exit',10,10
  9174.         dc.b    'OPTIONS:',10
  9175.         dc.b    'Sort       CLICmd    TaskInfo      TaskPorts    Hidden',10
  9176.         dc.b    'Usage      Header    UseScreen     UseWindow    UseTopaz',10
  9177.         dc.b    'PropGad    Iconify   BackDropIcon  SmartPatch   CxHandler',0
  9178.  
  9179. Template    dc.b    'CMD/K,KEEPIO/S,NOSCRIPT/S,CX_POPUP/K,CX_POPKEY/K,CX_PRIORITY/K/N: ',0
  9180. ArgCmd        dc.b    'CMD',0
  9181. ArgKill        dc.b    'KILL',0
  9182. ArgKeepIO    dc.b    'KEEPIO',0
  9183. ArgNoScript    dc.b    'NOSCRIPT',0
  9184. ArgCxPop    dc.b    'CX_POPUP',0
  9185. ArgCxKey    dc.b    'CX_POPKEY',0
  9186. ArgCxPri    dc.b    'CX_PRIORITY',0
  9187. ArgCxYes    dc.b    'YES',0
  9188. ArgHelp        dc.b    '?',0
  9189. DosName        dc.b    'dos.library',0
  9190. IcnName        dc.b    'icon.library',0
  9191. GfxName        dc.b    'graphics.library',0
  9192. IntName        dc.b    'intuition.library',0
  9193. CxName        dc.b    'commodities.library',0
  9194. WbName        dc.b    'workbench.library',0
  9195. DiskFont    dc.b    'diskfont.library',0
  9196. TdName        dc.b    'trackdisk.device',0
  9197. ConName        dc.b    'console.device',0
  9198. InputName    dc.b    'input.device',0
  9199. TimerName    dc.b    'timer.device',0
  9200. FontName    dc.b    'topaz.font',0
  9201. WbPortNam    dc.b    'Workbench',0
  9202. SetManNam    dc.b    'SetMan',0
  9203. StartupName
  9204.     IFND DEBUG
  9205.         dc.b    'ENV:Xoper.Startup',0
  9206.     ENDC
  9207.     IFD DEBUG
  9208.         dc.b    'ENV:Test.Startup',0
  9209.     ENDC
  9210.  
  9211.         cnop    0,4
  9212.  
  9213. dataarea    ds.b    gb_SIZEOF
  9214.  
  9215. DosTable    equ    _DosTable-dataarea
  9216.  
  9217. pubclr        equ    PubClr-dataarea
  9218. detached    equ    Detached-dataarea
  9219.  
  9220. stplist        equ    StpList-dataarea
  9221. fkeys        equ    FKeys-dataarea
  9222. history        equ    History-dataarea
  9223. curhist        equ    CurHist-dataarea
  9224.  
  9225. newbroker    equ    NewBroker-dataarea
  9226. ininterrupt    equ    InInterrupt-dataarea
  9227. iocounter    equ    IoCounter-dataarea
  9228. tattr        equ    TAttr-dataarea
  9229. window_l    equ    Window_l-dataarea
  9230. window_w    equ    Window_w-dataarea
  9231. newwindow    equ    NewWindow-dataarea
  9232. nwflgs        equ    NwFlgs-dataarea
  9233. nwscreen    equ    NwScreen-dataarea
  9234. nwtype        equ    NwType-dataarea
  9235. newscreen    equ    NewScreen-dataarea
  9236. newscrtags    equ    NewScrTags-dataarea
  9237. nsdisplay    equ    NsDisplay-dataarea
  9238. nspubname    equ    NsPubName-dataarea
  9239. nspubsig    equ    NsPubSig-dataarea
  9240.  
  9241. icnwindow    equ    IcnWindow-dataarea
  9242. appobj        equ    AppObj-dataarea
  9243. gadget        equ    Gadget-dataarea
  9244. image        equ    Image-dataarea
  9245. iconifgad    equ    IconifGad-dataarea
  9246. iconimg        equ    IconImg-dataarea
  9247.  
  9248. sbgadget    equ    SBGadget-dataarea
  9249. propinfo    equ    PropInfo-dataarea
  9250. sbdata        equ    SBData-dataarea
  9251.  
  9252. hextab        equ    HexTab-dataarea
  9253.  
  9254. params        equ    Params-dataarea
  9255.  
  9256. commds        equ    Commds-dataarea
  9257. newname        equ    NewName-dataarea
  9258. noname        equ    NoName-dataarea
  9259. xopcon        equ    XopCon-dataarea
  9260. xopsleep    equ    XopSleep-dataarea
  9261. memportname    equ    MemPortName-dataarea
  9262. IOcntname    equ    IOcntName-dataarea
  9263. kidlename    equ    KidleName-dataarea
  9264. namefmt        equ    NameFmt-dataarea
  9265. defhotkey    equ    DefHotkey-dataarea
  9266. verstring    equ    VerString-dataarea
  9267. copyright    equ    Copyright-dataarea
  9268. description    equ    Description-dataarea
  9269.  
  9270. t2header    equ    T2Header-dataarea
  9271. t3header    equ    T3Header-dataarea
  9272. t4header    equ    T4Header-dataarea
  9273. theader        equ    THeader-dataarea
  9274. lheader        equ    LHeader-dataarea
  9275. libnam        equ    LibNam-dataarea
  9276. devnam        equ    DevNam-dataarea
  9277. resnam        equ    ResNam-dataarea
  9278. mheader        equ    MHeader-dataarea
  9279. iheader        equ    IHeader-dataarea
  9280. inheader    equ    InHeader-dataarea
  9281. rheader        equ    RHeader-dataarea
  9282. pheader        equ    PHeader-dataarea
  9283. hunkheader    equ    HunkHeader-dataarea
  9284. ddheader    equ    DDHeader-dataarea
  9285. cdheader    equ    CDHeader-dataarea
  9286. ofheader    equ    OFHeader-dataarea
  9287. scrheader    equ    ScrHeader-dataarea
  9288. monitorid    equ    MonitorID-dataarea
  9289. pscrheader    equ    PScrHeader-dataarea
  9290. wnheader    equ    WnHeader-dataarea
  9291. fohead        equ    FoHead-dataarea
  9292. kickhead    equ    KickHead-dataarea
  9293. snoophead    equ    SnoopHead-dataarea
  9294. stackhead    equ    StackHead-dataarea
  9295. clicomhead    equ    CliComHead-dataarea
  9296. tiohead        equ    TioHead-dataarea
  9297. dchead        equ    DCHead-dataarea
  9298. alhead        equ    ALHead-dataarea
  9299. semhead        equ    SemHead-dataarea
  9300. fraghead    equ    FragHead-dataarea
  9301. fkhead        equ    FKHead-dataarea
  9302. fileshead    equ    FilesHead-dataarea
  9303. tddrives    equ    TDDrives-dataarea
  9304. unitmsg        equ    UnitMsg-dataarea
  9305. timerunits    equ    TimerUnits-dataarea
  9306. fmode        equ    FMode-dataarea
  9307. access        equ    Access-dataarea
  9308. romfnt        equ    RomFnt-dataarea
  9309. diskfnt        equ    DiskFnt-dataarea
  9310. ffixed        equ    FFixed-dataarea
  9311. fprop        equ    FProp-dataarea
  9312. status        equ    Status-dataarea
  9313. type        equ    Type-dataarea
  9314. tasktype    equ    TaskType-dataarea
  9315. softinttype    equ    SoftIntType-dataarea
  9316. proctype    equ    ProcType-dataarea
  9317. mp_flags    equ    Mp_Flags-dataarea
  9318. pscr_state    equ    PScr_State-dataarea
  9319. infoh2        equ    Infoh2-dataarea
  9320. infoh1        equ    Infoh1-dataarea
  9321. infoh3        equ    Infoh3-dataarea
  9322. infoh6        equ    Infoh6-dataarea
  9323. infoh4        equ    Infoh4-dataarea
  9324. infoh7        equ    Infoh7-dataarea
  9325. cpu0        equ    CPU0-dataarea
  9326. cpu1        equ    CPU1-dataarea
  9327. cpu2        equ    CPU2-dataarea
  9328. cpu3        equ    CPU3-dataarea
  9329. cpu4        equ    CPU4-dataarea
  9330. cpu5        equ    CPU5-dataarea
  9331. fpu0        equ    FPU0-dataarea
  9332. fpu1        equ    FPU1-dataarea
  9333. fpu2        equ    FPU2-dataarea
  9334. nofpu        equ    NoFPU-dataarea
  9335. nullstate    equ    NullState-dataarea
  9336. idle        equ    Idle-dataarea
  9337. busy        equ    Busy-dataarea
  9338. dontknow    equ    DontKnow-dataarea
  9339. devload        equ    DevLoad-dataarea
  9340. devnload    equ    DevnLoad-dataarea
  9341. inten        equ    IntEn-dataarea
  9342. intdis        equ    IntDis-dataarea
  9343. intserv        equ    IntServ-dataarea
  9344. inthand        equ    IntHand-dataarea
  9345. notfile        equ    NotFile-dataarea
  9346. longlongnix    equ    LongLongNix-dataarea
  9347. longnix        equ    LongNix-dataarea
  9348. nix        equ    Nix-dataarea
  9349. noinfo        equ    NoInfo-dataarea
  9350. oneblank    equ    OneBlank-dataarea
  9351. equal        equ    Equal-dataarea
  9352. openbrak    equ    OpenBrak-dataarea
  9353. closebrak    equ    CloseBrak-dataarea
  9354. namerr        equ    NameErr-dataarea
  9355. fonterr        equ    FontErr-dataarea
  9356. adrerr        equ    AdrErr-dataarea
  9357. aliaserr    equ    AliasErr-dataarea
  9358. aliaserr2    equ    AliasErr2-dataarea
  9359. noworkbench    equ    NoWorkbench-dataarea
  9360. openerr        equ    OpenErr-dataarea
  9361. listerr        equ    ListErr-dataarea
  9362. wiwerr        equ    WiwErr-dataarea
  9363. gurutxt        equ    GuruTxt-dataarea
  9364. clrtxt        equ    ClrTxt-dataarea
  9365. canerr0        equ    CanErr0-dataarea
  9366. canerr1        equ    CanErr1-dataarea
  9367. unloaderr    equ    UnloadErr-dataarea
  9368. noprocs        equ    NoProcs-dataarea
  9369. notload        equ    NotLoad-dataarea
  9370. cliprocs    equ    CliProcs-dataarea
  9371. procloaded    equ    ProcLoaded-dataarea
  9372. segloaded    equ    SegLoaded-dataarea
  9373. coldtxt        equ    ColdTxt-dataarea
  9374. cooltxt        equ    CoolTxt-dataarea
  9375. warmtxt        equ    WarmTxt-dataarea
  9376. kicktxt        equ    KickTxt-dataarea
  9377. unset        equ    Unset-dataarea
  9378. intnames    equ    IntNames-dataarea
  9379. inttyp        equ    IntTyp-dataarea
  9380.  
  9381. memnoexp    equ    MemNoExp-dataarea
  9382. memrev        equ    MemRev-dataarea
  9383. memlarg        equ    MemLarg-dataarea
  9384. memclr        equ    MemClr-dataarea
  9385. memkick        equ    MemKick-dataarea
  9386. memdma        equ    MemDMA-dataarea
  9387. memloc        equ    MemLoc-dataarea
  9388. memfast        equ    MemFast-dataarea
  9389. memchip        equ    MemChip-dataarea
  9390. mempubl        equ    MemPubl-dataarea
  9391.  
  9392. failed        equ    Failed-dataarea
  9393. allok        equ    AllOk-dataarea
  9394. free        equ    Free-dataarea
  9395. backg        equ    Backg-dataarea
  9396. foreg        equ    Foreg-dataarea
  9397. script        equ    Script-dataarea
  9398. interact    equ    Interact-dataarea
  9399. nameerr        equ    NameErr-dataarea
  9400. synerr        equ    SynErr-dataarea
  9401. cr        equ    CR-dataarea
  9402. dnotf        equ    Dnotf-dataarea
  9403. notdir        equ    NotDir-dataarea
  9404. nomount        equ    NoMount-dataarea
  9405. dishelp        equ    DisHelp-dataarea
  9406. unlerr        equ    UnlErr-dataarea
  9407. unl1        equ    Unl1-dataarea
  9408. unltxt        equ    UnlTxt-dataarea
  9409. unltxt2        equ    UnlTxt2-dataarea
  9410. scnofound    equ    ScNoFound-dataarea
  9411. winnofound    equ    WinNoFound-dataarea
  9412. stperr        equ    StpErr-dataarea
  9413. waerr        equ    WaErr-dataarea
  9414. whatsthis    equ    WhatsThis-dataarea
  9415. toomuch        equ    TooMuch-dataarea
  9416. timenotset    equ    TimeNotSet-dataarea
  9417. whattime    equ    WhatTime-dataarea
  9418. stopped        equ    Stopped-dataarea
  9419. capexited    equ    CapExited-dataarea
  9420. capwait        equ    CapWait-dataarea
  9421. onscr        equ    OnScr-dataarea
  9422. whatnow        equ    WhatNow-dataarea
  9423. noguru        equ    NoGuru-dataarea
  9424. softfail    equ    SoftFail-dataarea
  9425. addrserr    equ    AddrsErr-dataarea
  9426. procount    equ    ProCount-dataarea
  9427. memtyp        equ    MemTyp-dataarea
  9428. nintrserv    equ    NintrServ-dataarea
  9429. onstr        equ    OnStr-dataarea
  9430. offstr        equ    OffStr-dataarea
  9431. usetxt        equ    UseTxt-dataarea
  9432. template    equ    Template-dataarea
  9433. argcmd        equ    ArgCmd-dataarea
  9434. argkill        equ    ArgKill-dataarea
  9435. argkeepio    equ    ArgKeepIO-dataarea
  9436. argnoscript    equ    ArgNoScript-dataarea
  9437. argcxpop    equ    ArgCxPop-dataarea
  9438. argcxkey    equ    ArgCxKey-dataarea
  9439. argcxpri    equ    ArgCxPri-dataarea
  9440. argcxyes    equ    ArgCxYes-dataarea
  9441. arghelp        equ    ArgHelp-dataarea
  9442. dosname        equ    DosName-dataarea
  9443. icnname        equ    IcnName-dataarea
  9444. gfxname        equ    GfxName-dataarea
  9445. intname        equ    IntName-dataarea
  9446. cxname        equ    CxName-dataarea
  9447. wbname        equ    WbName-dataarea
  9448. diskfont    equ    DiskFont-dataarea
  9449. tdname        equ    TdName-dataarea
  9450. conname        equ    ConName-dataarea
  9451. inputname    equ    InputName-dataarea
  9452. timername    equ    TimerName-dataarea
  9453. fontname    equ    FontName-dataarea
  9454. fontsuf        equ    fontname+5
  9455. wbportnam    equ    WbPortNam-dataarea
  9456. setmannam    equ    SetManNam-dataarea
  9457. deffont        equ    DefFont-dataarea
  9458. startupname    equ    StartupName-dataarea
  9459.  
  9460.         SECTION Images,DATA,CHIP
  9461.  
  9462. IconifData    dc.w    $7FFF,$FFFC,$601F,$FFFC,$6000,$000C,$607F,$FFCC
  9463.         dc.w    $6060,$00CC,$6067,$FCCC,$7E60,$00CC,$7E7F,$FFCC
  9464.         dc.w    $7E00,$000C,$7FFF,$FFFC,$0000,$0000,$1FE0,$0000
  9465.         dc.w    $1FFF,$FFF0,$1F80,$0030,$1F9F,$FF30,$1F98,$0330
  9466.         dc.w    $019F,$FF30,$0180,$0030,$01FF,$FFF0,$0000,$0000
  9467.  
  9468. ImageData    dc.w    $000F,$FFFF,$FFFF,$FFF8,$0000,$001F,$FFFF,$FFFF
  9469.         dc.w    $FFFC,$0000,$001F,$0000,$0000,$007C,$0000,$001F
  9470.         dc.w    $7FFF,$FFFF,$FF7C,$0000,$001F,$4A46,$0244,$557C
  9471.         dc.w    $0000,$001F,$5108,$D411,$817C,$0000,$001F,$7FFF
  9472.         dc.w    $FFFF,$FF7C,$0000,$001F,$0000,$0000,$007C,$0000
  9473.         dc.w    $001F,$30C0,$0000,$007C,$0000,$001F,$1980,$0000
  9474.         dc.w    $007C,$0000,$001F,$0F0F,$1F0F,$1F7C,$0000,$001F
  9475.         dc.w    $0619,$9999,$997C,$0000,$001F,$0F19,$999F,$987C
  9476.         dc.w    $0000,$001F,$1999,$9F18,$187C,$0000,$001F,$30CF
  9477.         dc.w    $180F,$187C,$0000,$001F,$0000,$1800,$007C,$0000
  9478.         dc.w    $001F,$0000,$0000,$007C,$0000,$001F,$FFFF,$FFFF
  9479.         dc.w    $FFFC,$0000,$000F,$FFFF,$FFFF,$FF18,$0000,$0000
  9480.         dc.w    $0000,$0000,$0000,$0000,$3FFF,$FFFF,$FFFF,$FFFF
  9481.         dc.w    $FC00,$FDFF,$FFFF,$FFFF,$FFFF,$FF00,$EBFF,$FFFF
  9482.         dc.w    $FFFF,$FFFF,$FF00,$F7FF,$FFFF,$FFFF,$F800,$0700
  9483.         dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FF00,$FFFF,$FFFF,$FFFF
  9484.         dc.w    $FFFF,$FF00,$FFFF,$FFFF,$FFFF,$FFFF,$FF00,$3FFF
  9485.         dc.w    $FFFF,$FFFF,$FFFF,$FC00,$0000,$0000,$0000,$0000
  9486.         dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$FFFF
  9487.         dc.w    $FFFF,$FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000
  9488.         dc.w    $0000,$FFFF,$FFFF,$FF80,$0000,$0000,$FFFF,$FFFF
  9489.         dc.w    $FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000,$0000
  9490.         dc.w    $FFFF,$FFFF,$FF80,$0000,$0000,$8000,$0000,$0080
  9491.         dc.w    $0000,$0000,$8000,$0000,$0080,$0000,$0000,$8000
  9492.         dc.w    $0000,$0080,$0000,$0000,$8000,$0000,$0080,$0000
  9493.         dc.w    $0000,$8000,$0000,$0080,$0000,$0000,$8000,$0000
  9494.         dc.w    $0080,$0000,$0000,$8000,$0000,$0080,$0000,$0000
  9495.         dc.w    $8000,$0000,$0080,$0000,$0000,$FFFF,$FFFF,$FF80
  9496.         dc.w    $0000,$0000,$0000,$0000,$00E0,$0000,$0000,$0000
  9497.         dc.w    $0000,$00E0,$0000,$0000,$1FFF,$FFFF,$F800,$0000
  9498.         dc.w    $0000,$0080,$0040,$0000,$0000,$0200,$0080,$0040
  9499.         dc.w    $0000,$0000,$1400,$0080,$0040,$003F,$0000,$0800
  9500.         dc.w    $0080,$0040,$07FF,$F800,$0000,$0080,$0040,$003F
  9501.         dc.w    $0000,$0000,$0080,$0040,$0000,$3800,$FFFF,$FFFF
  9502.         dc.w    $FFFF,$FFFF,$FE00,$0000,$0080,$0040,$0000,$0000
  9503.  
  9504. imagesize    equ    (((*-ImageData)>>2)-1)
  9505.  
  9506.         end
  9507.